Zelda Classic Coverage Report


Directory: src/
File: src/zc/ffscript.cpp
Date: 2023-08-14 04:22:47
Exec Total Coverage
Lines: 5332 24412 21.8%
Functions: 300 1037 28.9%
Branches: 3154 19240 16.4%

Line Branch Exec Source
1 #include <deque>
2 #include <string>
3 #include <sstream>
4 #include <math.h>
5 #include <cstdio>
6 //
7 #include <sys/types.h>
8 #include <sys/stat.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <fstream>
12 #include <filesystem>
13 #include <fmt/format.h>
14 //
15
16 #include "base/qrs.h"
17 #include "base/dmap.h"
18 #include "base/msgstr.h"
19 #include "base/packfile.h"
20 #include "base/misctypes.h"
21 #include "zc/zc_sys.h"
22 #include "zc/jit.h"
23 #include "zc/script_debug.h"
24 #include "base/zc_alleg.h"
25 #include "base/zc_math.h"
26 #include "base/zc_array.h"
27 #include "zc/ffscript.h"
28 #include "zc/render.h"
29 #include "zc/zc_subscr.h"
30 #include <time.h>
31 #include "zc/script_drawing.h"
32 #include "base/util.h"
33 #include "zc/ending.h"
34 #include "base/module.h"
35 #include "zc/combos.h"
36 #include "drawing.h"
37 #include "base/colors.h"
38 #include "pal.h"
39 #include "zinfo.h"
40 #include <sstream>
41
42 #ifdef _WIN32
43 #define SCRIPT_FILE_MODE (_S_IREAD | _S_IWRITE)
44 #else
45 #include <fcntl.h>
46 #include <unistd.h>
47 #include <iostream>
48 #define SCRIPT_FILE_MODE (S_ISVTX | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
49 #endif
50
51 //Define this register, so it can be treated specially
52 #define NUL 5
53 #define MAX_ZC_ARRAY_SIZE 214748
54
55 // #define _SCRIPT_COUNTER
56
57 #ifdef _SCRIPT_COUNTER
58 static int64_t script_timer[NUMCOMMANDS];
59 static int64_t script_execount[NUMCOMMANDS];
60 #endif
61
62 using namespace util;
63 using std::ostringstream;
64
65 extern byte use_dwm_flush;
66 uint8_t using_SRAM = 0;
67
68 extern zinitdata zinit;
69 int32_t hangcount = 0;
70 bool can_neg_array = true;
71
72 extern byte monochrome_console;
73
74 232 static std::set<int> seen_scripts;
75 116 static std::map<int, ScriptDebugHandle> script_debug_handles;
76 ScriptDebugHandle* runtime_script_debug_handle;
77 116 static std::map<std::pair<script_data*, refInfo*>, JittedScriptHandle*> jitted_scripts;
78 int32_t jitted_uncompiled_command_count;
79
80 116 CScriptDrawingCommands scriptdraws;
81 116 FFScript FFCore;
82 ZModule zcm;
83 zcmodule moduledata;
84 116 script_bitmaps scb;
85
3/4
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29580 times.
✓ Branch 3 taken 116 times.
29696 user_file script_files[MAX_USER_FILES];
86
3/4
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29580 times.
✓ Branch 3 taken 116 times.
29696 user_dir script_dirs[MAX_USER_DIRS];
87
3/4
✓ Branch 0 taken 24910768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24910652 times.
✓ Branch 3 taken 116 times.
24910768 user_object script_objects[MAX_USER_OBJECTS];
88
3/4
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29580 times.
✓ Branch 3 taken 116 times.
29696 user_stack script_stacks[MAX_USER_STACKS];
89 116 user_rng nulrng;
90 116 user_rng script_rngs[MAX_USER_RNGS];
91 116 zc_randgen script_rnggens[MAX_USER_RNGS];
92 user_paldata script_paldatas[MAX_USER_PALDATAS];
93
94 FONT *get_zc_font(int index);
95
96 int32_t combopos_modified = -1;
97 static word combo_id_cache[7*176] = {0};
98
99 57856 void user_dir::clear()
100 {
101 57856 filepath = "";
102 57856 reserved = false;
103 57856 owned_type = (ScriptType)-1;
104 57856 owned_i = 0;
105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57856 times.
57856 if(list)
106 {
107 list->clear();
108 free(list);
109 list = NULL;
110 }
111 57856 }
112 void user_dir::setPath(const char* buf)
113 {
114 if(!list)
115 {
116 list = (FLIST *) malloc(sizeof(FLIST));
117 }
118 reserved = true;
119 filepath = std::string(buf) + "/";
120 regulate_path(filepath);
121 list->load(filepath.c_str());
122 }
123
124 int32_t CScriptDrawingCommands::GetCount()
125 {
126 al_trace("current number of draws is: %d\n", count);
127 return count;
128 }
129 //Advances the game frame without checking 'Quit' variable status.
130 //Used for making scripts such as Player's onWin and onDeath scripts
131 //run for multiple frames.
132
133 void FFScript::Waitframe(bool allowwavy, bool sfxcleanup)
134 {
135 if(zcmusic!=NULL)
136 {
137 zcmusic_poll();
138 }
139 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
140
141 while(Paused && !Advance && !Quit)
142 {
143 // have to call this, otherwise we'll get an infinite loop
144 syskeys();
145 // to keep fps constant
146 updatescr(allowwavy);
147 throttleFPS();
148
149 #ifdef _WIN32
150
151 if(use_dwm_flush)
152 {
153 do_DwmFlush();
154 }
155
156 #endif
157
158 // to keep music playing
159 if(zcmusic!=NULL)
160 {
161 zcmusic_poll();
162 }
163 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
164
165 update_hw_screen();
166 }
167
168 //if(Quit)
169 // return;
170 /*
171 if(Playing && game->get_time()<MAXTIME)
172 game->change_time(1);
173 */
174 Advance=false;
175 ++frame;
176
177 syskeys();
178 // Someday... maybe install a Turbo button here?
179 updatescr(allowwavy);
180 throttleFPS();
181
182 #ifdef _WIN32
183
184 if(use_dwm_flush)
185 {
186 do_DwmFlush();
187 }
188
189 #endif
190
191 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
192 if(sfxcleanup)
193 sfx_cleanup();
194 }
195
196 18561592 mapscr* GetMapscr(int32_t mapref)
197 {
198
6/15
✓ Branch 0 taken 30619 times.
✓ Branch 1 taken 17428017 times.
✓ Branch 2 taken 135370 times.
✓ Branch 3 taken 16181 times.
✓ Branch 4 taken 1957 times.
✓ Branch 5 taken 949448 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
18561592 switch(mapref)
199 {
200 30619 case MAPSCR_TEMP0: return FFCore.tempScreens[0]; //Temp layer 0
201 135370 case MAPSCR_TEMP1: return FFCore.tempScreens[1]; //Temp layer 1
202 16181 case MAPSCR_TEMP2: return FFCore.tempScreens[2]; //Temp layer 2
203 1957 case MAPSCR_TEMP3: return FFCore.tempScreens[3]; //Temp layer 3
204 949448 case MAPSCR_TEMP4: return FFCore.tempScreens[4]; //Temp layer 4
205 case MAPSCR_TEMP5: return FFCore.tempScreens[5]; //Temp layer 5
206 case MAPSCR_TEMP6: return FFCore.tempScreens[6]; //Temp layer 6
207 case MAPSCR_SCROLL0: return FFCore.ScrollingScreens[0]; //Temp scrolllayer 0
208 case MAPSCR_SCROLL1: return FFCore.ScrollingScreens[1]; //Temp scrolllayer 1
209 case MAPSCR_SCROLL2: return FFCore.ScrollingScreens[2]; //Temp scrolllayer 2
210 case MAPSCR_SCROLL3: return FFCore.ScrollingScreens[3]; //Temp scrolllayer 3
211 case MAPSCR_SCROLL4: return FFCore.ScrollingScreens[4]; //Temp scrolllayer 4
212 case MAPSCR_SCROLL5: return FFCore.ScrollingScreens[5]; //Temp scrolllayer 5
213 case MAPSCR_SCROLL6: return FFCore.ScrollingScreens[6]; //Temp scrolllayer 6
214 default:
215 {
216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17428017 times.
17428017 if(mapref < 0) return NULL; //Bad negative value
217 17428017 else return &TheMaps[mapref]; //Standard mapdata
218 }
219 }
220 18561592 }
221
222 18 int32_t getMap(int32_t ref)
223 {
224
1/15
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
18 switch(ref)
225 {
226 case MAPSCR_TEMP0:
227 return currmap+1;
228 case MAPSCR_TEMP1:
229 return FFCore.tempScreens[0]->layermap[0];
230 case MAPSCR_TEMP2:
231 return FFCore.tempScreens[0]->layermap[1];
232 case MAPSCR_TEMP3:
233 return FFCore.tempScreens[0]->layermap[2];
234 case MAPSCR_TEMP4:
235 return FFCore.tempScreens[0]->layermap[3];
236 case MAPSCR_TEMP5:
237 return FFCore.tempScreens[0]->layermap[4];
238 case MAPSCR_TEMP6:
239 return FFCore.tempScreens[0]->layermap[5];
240 case MAPSCR_SCROLL0:
241 return scrolling_map+1;
242 case MAPSCR_SCROLL1:
243 return FFCore.ScrollingScreens[0]->layermap[0];
244 case MAPSCR_SCROLL2:
245 return FFCore.ScrollingScreens[0]->layermap[1];
246 case MAPSCR_SCROLL3:
247 return FFCore.ScrollingScreens[0]->layermap[2];
248 case MAPSCR_SCROLL4:
249 return FFCore.ScrollingScreens[0]->layermap[3];
250 case MAPSCR_SCROLL5:
251 return FFCore.ScrollingScreens[0]->layermap[4];
252 case MAPSCR_SCROLL6:
253 return FFCore.ScrollingScreens[0]->layermap[5];
254 default:
255 18 return (ref / MAPSCRS + 1);
256 }
257 18 }
258 42 int32_t getScreen(int32_t ref)
259 {
260
1/15
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
42 switch(ref)
261 {
262 case MAPSCR_TEMP0:
263 return currscr;
264 case MAPSCR_TEMP1:
265 return FFCore.tempScreens[0]->layerscreen[0];
266 case MAPSCR_TEMP2:
267 return FFCore.tempScreens[0]->layerscreen[1];
268 case MAPSCR_TEMP3:
269 return FFCore.tempScreens[0]->layerscreen[2];
270 case MAPSCR_TEMP4:
271 return FFCore.tempScreens[0]->layerscreen[3];
272 case MAPSCR_TEMP5:
273 return FFCore.tempScreens[0]->layerscreen[4];
274 case MAPSCR_TEMP6:
275 return FFCore.tempScreens[0]->layerscreen[5];
276 case MAPSCR_SCROLL0:
277 return scrolling_scr;
278 case MAPSCR_SCROLL1:
279 return FFCore.ScrollingScreens[0]->layerscreen[0];
280 case MAPSCR_SCROLL2:
281 return FFCore.ScrollingScreens[0]->layerscreen[1];
282 case MAPSCR_SCROLL3:
283 return FFCore.ScrollingScreens[0]->layerscreen[2];
284 case MAPSCR_SCROLL4:
285 return FFCore.ScrollingScreens[0]->layerscreen[3];
286 case MAPSCR_SCROLL5:
287 return FFCore.ScrollingScreens[0]->layerscreen[4];
288 case MAPSCR_SCROLL6:
289 return FFCore.ScrollingScreens[0]->layerscreen[5];
290 default:
291 42 return (ref % MAPSCRS);
292 }
293 42 }
294
295 #include "zconsole/ConsoleLogger.h"
296
297 //no ifdef here
298 116 CConsoleLoggerEx coloured_console;
299 extern CConsoleLoggerEx zscript_coloured_console;
300
301 int32_t FFScript::UpperToLower(std::string *s)
302 {
303 if ( s->size() < 1 )
304 {
305 Z_scripterrlog("String passed to UpperToLower() is too small. Size is: %d \n", s->size());
306 return 0;
307 }
308 for ( size_t q = 0; q < s->size(); ++q )
309 {
310 //if ( s->at(q) >= 'A' || s->at(q) <= 'Z' )
311 //{
312 // s->at(q) += 32;
313 //}
314 s->at(q) += 32 * (s->at(q) >= 'A' && s->at(q) <= 'Z');
315 }
316 return 1;
317 }
318
319 int32_t FFScript::LowerToUpper(std::string *s)
320 {
321 if ( s->size() < 1 )
322 {
323 Z_scripterrlog("String passed to LowerToUpper() is too small. Size is: %d \n", s->size());
324 return 0;
325 }
326 for ( size_t q = 0; q < s->size(); ++q )
327 {
328 //if ( s->at(q) >= 'a' || s->at(q) <= 'z' )
329 //{
330 // s->at(q) -= 32;
331 //}
332 s->at(q) -= 32 * (s->at(q) >= 'a' && s->at(q) <= 'z');
333 }
334 return 1;
335 }
336
337 int32_t FFScript::ConvertCase(std::string *s)
338 {
339 if ( s->size() < 1 )
340 {
341 Z_scripterrlog("String passed to UpperToLower() is too small. Size is: %d \n", s->size());
342 return 0;
343 }
344 for ( size_t q = 0; q < s->size(); ++q )
345 {
346 if ( s->at(q) >= 'a' || s->at(q) <= 'z' )
347 {
348 s->at(q) -= 32;
349 }
350 else if ( s->at(q) >= 'A' || s->at(q) <= 'Z' )
351 {
352 s->at(q) += 32;
353 }
354 }
355 zprint("FFScript::ConvertCase(std::string s), post-conversion, string is: %s\n", s->c_str());
356 return 1;
357 }
358
359 bool FFScript::isNumber(char chr)
360 {
361 if ( chr >= '0' )
362 {
363 if ( chr <= '9' ) return true;
364 }
365 return false;
366 }
367
368 int32_t FFScript::ilen(char *p)
369 {
370 int32_t ret = 0; int32_t pos = 0;
371 if(p[pos] == '-')
372 ret++;
373 for(; FFCore.isNumber(p[pos + ret]); ++ret);
374 return ret;
375 }
376
377 int32_t FFScript::zc_strlen(char *p)
378 {
379 int32_t count = 0;
380
381 while(*p!='\0')
382 {
383 count++;
384 p++;
385 }
386
387 return count;
388 }
389
390 int32_t FFScript::atox(char *ip_str)
391 {
392 char tmp[2]={'2','\0'};
393 int32_t op_val=0, i=0, ip_len = FFCore.zc_strlen(ip_str);
394
395 if(strncmp(ip_str, "0x", 2) == 0)
396 {
397 ip_str +=2;
398 ip_len -=2;
399 }
400
401 for(i=0;i<ip_len;i++)
402 {
403 op_val *= 0x10;
404 switch(ip_str[i])
405 {
406 case 'a':
407 op_val += 0xa;
408 break;
409 case 'b':
410 op_val += 0xb;
411 break;
412 case 'c':
413 op_val += 0xc;
414 break;
415 case 'd':
416 op_val += 0xd;
417 break;
418 case 'e':
419 op_val += 0xe;
420 break;
421 case 'f':
422 op_val += 0xf;
423 break;
424 case '0':
425 case '1':
426 case '2':
427 case '3':
428 case '4':
429 case '5':
430 case '6':
431 case '7':
432 case '8':
433 case '9':
434 tmp[0] = ip_str[i];
435 op_val += atoi(tmp);
436 break;
437 default :
438 op_val += 0x0;
439 break;
440 }
441 }
442 return op_val;
443 }
444
445 char runningItemScripts[256] = {0};
446
447 //item *FFCore.temp_ff_item = NULL;
448 //enemy *FFCore.temp_ff_enemy = NULL;
449 //weapon *FFCore.temp_ff_lweapon = NULL;
450 //weapon *FFCore.temp_ff_eweapon = NULL;
451
452 #include "zc/zelda.h"
453 #include "particles.h"
454 #include "zc/hero.h"
455 extern int32_t directItem; //Is set if Player is currently using an item directly
456 extern int32_t directItemA;
457 extern int32_t directItemB;
458 extern int32_t directItemX;
459 extern int32_t directItemY;
460
461 #include "zc/guys.h"
462 #include "gamedata.h"
463 #include "zc/zc_init.h"
464 #include "base/zsys.h"
465 #include "base/misctypes.h"
466 #include "zc/title.h"
467 #include "zscriptversion.h"
468
469 #include "pal.h"
470 #include "base/zdefs.h"
471 #include "zc/rendertarget.h"
472
473 #include "zc/zc_custom.h"
474 #include "qst.h"
475
476 #define zc_max(a,b) ((a)>(b)?(a):(b))
477 /*template <typename T>
478 T zc_max(T a, T b)
479 {
480 return (a > b) ? a : b;
481 }*/
482
483 #define zc_min(a,b) ((a)<(b)?(a):(b))
484
485 #ifdef _MSC_VER
486 #pragma warning ( disable : 4800 ) //int32_t to bool town. population: lots.
487 #endif
488
489 #define NUMSHOPS 256
490 #define NUMINFOSHOPS 511
491
492 //! New datatype vars for 2.54:
493
494 //spritedata sp->member
495
496
497 using std::string;
498
499 extern particle_list particles;
500 extern HeroClass Hero;
501 extern char *guy_string[];
502 extern int32_t skipcont;
503
504 PALETTE tempgreypal; //Palettes go here. This is used for Greyscale() / Monochrome()
505 PALETTE userPALETTE[256]; //Palettes go here. This is used for Greyscale() / Monochrome()
506 PALETTE tempblackpal; //Used for storing the palette while fading to black
507
508 116 FFScript ffengine;
509
510 byte FF_hero_action; //This way, we can make safe replicas of internal Hero actions to be set by script.
511
512 int32_t FF_screenbounds[4]; //edges of the screen, left, right, top, bottom used for where to scroll.
513 int32_t FF_screen_dimensions[4]; //height, width, displaywidth, displayheight
514 int32_t FF_subscreen_dimensions[4];
515 int32_t FF_eweapon_removal_bounds[4]; //left, right, top, bottom coordinates for automatic eweapon removal.
516 int32_t FF_lweapon_removal_bounds[4]; //left, right, top, bottom coordinates for automatic lweapon removal.
517 int32_t FF_clocks[FFSCRIPTCLASS_CLOCKS]; //Will be used for Heroaction, anims, and so forth
518 byte ScriptDrawingRules[SCRIPT_DRAWING_RULES];
519 int32_t FF_UserMidis[NUM_USER_MIDI_OVERRIDES]; //MIDIs to use for Game Over, and similar to override system defaults.
520
521 int32_t get_int_arr(const int32_t ptr, int32_t indx);
522 void set_int_arr(const int32_t ptr, int32_t indx, int32_t val);
523 int32_t sz_int_arr(const int32_t ptr);
524
525 //We gain some speed by not passing as arguments
526 int32_t sarg1 = 0;
527 int32_t sarg2 = 0;
528 std::vector<int32_t> *sargvec;
529 std::string *sargstr;
530 refInfo *ri = NULL;
531 script_data *curscript = NULL;
532 int32_t(*stack)[MAX_SCRIPT_REGISTERS] = NULL;
533 std::vector<int32_t> zs_vargs;
534 ScriptType curScriptType;
535 word curScriptNum;
536 int32_t curScriptIndex;
537 bool script_funcrun = false;
538 std::string* destructstr = nullptr;
539
540 static std::vector<ScriptType> curScriptType_cache;
541 static std::vector<int32_t> curScriptNum_cache;
542 static std::vector<int32_t> curScriptIndex_cache;
543 static std::vector<int32_t> sarg1cache;
544 static std::vector<int32_t> sarg2cache;
545 static std::vector<std::vector<int32_t>*> sargvec_cache;
546 static std::vector<std::string*> sargstr_cache;
547 static std::vector<refInfo*> ricache;
548 static std::vector<script_data*> sdcache;
549 static std::vector<int32_t(*)[MAX_SCRIPT_REGISTERS]> stackcache;
550 10 void push_ri()
551 {
552 10 sarg1cache.push_back(sarg1);
553 10 sarg2cache.push_back(sarg2);
554 10 curScriptType_cache.push_back(curScriptType);
555 10 curScriptNum_cache.push_back(curScriptNum);
556 10 curScriptIndex_cache.push_back(curScriptIndex);
557 10 sargvec_cache.push_back(sargvec);
558 10 sargstr_cache.push_back(sargstr);
559 10 ricache.push_back(ri);
560 10 sdcache.push_back(curscript);
561 10 stackcache.push_back(stack);
562 10 }
563 10 void pop_ri()
564 {
565 10 sarg1 = sarg1cache.back(); sarg1cache.pop_back();
566 10 sarg2 = sarg2cache.back(); sarg2cache.pop_back();
567 10 curScriptType = curScriptType_cache.back(); curScriptType_cache.pop_back();
568 10 curScriptNum = curScriptNum_cache.back(); curScriptNum_cache.pop_back();
569 10 curScriptIndex = curScriptIndex_cache.back(); curScriptIndex_cache.pop_back();
570 10 sargvec = sargvec_cache.back(); sargvec_cache.pop_back();
571 10 sargstr = sargstr_cache.back(); sargstr_cache.pop_back();
572 10 ri = ricache.back(); ricache.pop_back();
573 10 curscript = sdcache.back(); sdcache.pop_back();
574 10 stack = stackcache.back(); stackcache.pop_back();
575 10 }
576
577 static int32_t numInstructions = 0; // Used to detect hangs
578 static bool scriptCanSave = true;
579
580 std::vector<refInfo*> genericActiveData;
581 std::vector<int32_t(*)[MAX_SCRIPT_REGISTERS]> generic_active_stack;
582 bool gen_active_doscript = false, gen_active_initialized = false;
583
584 284366 struct ScriptEngineData {
585 refInfo ref;
586 int32_t stack[MAX_SCRIPT_REGISTERS];
587 // This is used as a boolean for all but ScriptType::Item.
588 284366 byte doscript = true;
589 bool waitdraw;
590 bool initialized;
591
592 2574967 void reset()
593 {
594 // No need to zero the stack.
595 2574967 ref = refInfo();
596 2574967 doscript = true;
597 2574967 waitdraw = false;
598 2574967 initialized = false;
599 2574967 }
600 };
601
602 // (type, index) => ScriptEngineData
603 116 static std::map<std::pair<ScriptType, word>, ScriptEngineData> scriptEngineDatas;
604
605 349523155 static ScriptEngineData& get_script_engine_data(ScriptType type, int index)
606 {
607
8/8
✓ Branch 0 taken 333234545 times.
✓ Branch 1 taken 16288610 times.
✓ Branch 2 taken 333234428 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 316959844 times.
✓ Branch 5 taken 16274584 times.
✓ Branch 6 taken 17757 times.
✓ Branch 7 taken 316942087 times.
349523155 if (type == ScriptType::DMap || type == ScriptType::OnMap || type == ScriptType::PassiveSubscreen || type == ScriptType::ActiveSubscreen)
608 {
609 // `index` is used for dmapref, not for different script engine data.
610 32581068 index = 0;
611 32581068 }
612
613 349523155 return scriptEngineDatas[{type, index}];
614 }
615
616 44 static ScriptEngineData& get_script_engine_data(ScriptType type)
617 {
618 44 return scriptEngineDatas[{type, 0}];
619 }
620
621 408 void FFScript::clear_script_engine_data()
622 {
623 408 scriptEngineDatas.clear();
624 408 }
625
626 2112119 void FFScript::reset_script_engine_data(ScriptType type, int index)
627 {
628 2112119 get_script_engine_data(type, index).reset();
629 2112119 }
630
631 163913 void FFScript::clear_script_engine_data(ScriptType type, int index)
632 {
633
4/8
✓ Branch 0 taken 163913 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163913 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 163913 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 163913 times.
163913 if (type == ScriptType::DMap || type == ScriptType::OnMap || type == ScriptType::PassiveSubscreen || type == ScriptType::ActiveSubscreen)
634 {
635 // `index` is used for dmapref, not for different script engine data.
636 index = 0;
637 }
638
639 163913 auto it = scriptEngineDatas.find({type, index});
640
2/2
✓ Branch 0 taken 163861 times.
✓ Branch 1 taken 52 times.
163913 if (it != scriptEngineDatas.end())
641 {
642 52 scriptEngineDatas.erase(it);
643 52 }
644 163913 }
645
646 58862 void FFScript::clear_script_engine_data_of_type(ScriptType type)
647 {
648 38008933 std::erase_if(scriptEngineDatas, [&](auto& kv) { return kv.first.first == type; });
649 58862 }
650
651 194 refInfo& FFScript::ref(ScriptType type, int index)
652 {
653 194 return get_script_engine_data(type, index).ref;
654 }
655
656 32452820 byte& FFScript::doscript(ScriptType type, int index)
657 {
658 32452820 return get_script_engine_data(type, index).doscript;
659 }
660
661 267129393 bool& FFScript::waitdraw(ScriptType type, int index)
662 {
663 267129393 return get_script_engine_data(type, index).waitdraw;
664 }
665
666 // Returns true if registers had to be initialized.
667 8919074 static bool set_current_script_engine_data(ScriptType type, int script, int index)
668 {
669 8919074 bool got_initialized = false;
670
671 8919074 auto& data = get_script_engine_data(type, index);
672 8919074 ri = &data.ref;
673 8919074 stack = &data.stack;
674
675
10/11
✓ Branch 0 taken 271329 times.
✓ Branch 1 taken 9910 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4681458 times.
✓ Branch 4 taken 4287 times.
✓ Branch 5 taken 3886494 times.
✓ Branch 6 taken 13747 times.
✓ Branch 7 taken 114 times.
✓ Branch 8 taken 12244 times.
✓ Branch 9 taken 1402 times.
✓ Branch 10 taken 38089 times.
8919074 switch (type)
676 {
677 case ScriptType::FFC:
678 {
679 4681458 curscript = ffscripts[script];
680
681
2/2
✓ Branch 0 taken 4665801 times.
✓ Branch 1 taken 15657 times.
4681458 if (!data.initialized)
682 {
683 15657 got_initialized = true;
684 15657 memcpy(ri->d, tmpscr->ffcs[index].initd, 8 * sizeof(int32_t));
685 15657 memcpy(ri->a, tmpscr->ffcs[index].inita, 2 * sizeof(int32_t));
686 15657 data.initialized = true;
687 15657 }
688
689 4681458 ri->ffcref = index;
690 }
691 4681458 break;
692
693 // case ScriptType::NPC:
694 // {
695 // int32_t npc_index = GuyH::getNPCIndex(i);
696 // enemy *w = (enemy*)guys.spr(npc_index);
697 // ri = &(w->scrmem->scriptData);
698 // curscript = guyscripts[w->script];
699 // stack = &(w->scrmem->stack);
700 // ri->guyref = i;
701
702 // if (!w->initialised)
703 // {
704 // got_initialized = true;
705 // for ( int32_t q = 0; q < 8; q++ )
706 // {
707 // ri->d[q] = w->initD[q];
708 // }
709 // w->initialised = 1;
710 // }
711 // }
712 // break;
713
714 // case ScriptType::Lwpn:
715 // {
716 // int32_t lwpn_index = LwpnH::getLWeaponIndex(i);
717 // weapon *w = (weapon*)Lwpns.spr(lwpn_index);
718 // ri = &(w->scrmem->scriptData);
719 // curscript = lwpnscripts[w->weaponscript];
720 // stack = &(w->scrmem->stack);
721 // ri->lwpn = i;
722
723 // if (!w->initialised)
724 // {
725 // got_initialized = true;
726 // for ( int32_t q = 0; q < 8; q++ )
727 // {
728 // ri->d[q] = w->weap_initd[q]; //w->initiald[q];
729 // }
730 // w->initialised = 1;
731 // }
732 // }
733 // break;
734
735 // case ScriptType::Ewpn:
736 // {
737 // int32_t ewpn_index = EwpnH::getEWeaponIndex(i);
738 // weapon *w = (weapon*)Ewpns.spr(ewpn_index);
739 // ri = &(w->scrmem->scriptData);
740 // curscript = ewpnscripts[w->weaponscript];
741 // stack = &(w->scrmem->stack);
742 // ri->ewpn = i;
743
744 // if (!w->initialised)
745 // {
746 // got_initialized = true;
747 // for ( int32_t q = 0; q < 8; q++ )
748 // {
749 // ri->d[q] = w->weap_initd[q];
750 // }
751 // w->initialised = 1;
752 // }
753 // }
754 // break;
755
756 // case ScriptType::ItemSprite:
757 // {
758 // int32_t the_index = ItemH::getItemIndex(i);
759 // item *w = (item*)items.spr(the_index);
760 // ri = &(w->scrmem->scriptData);
761 // curscript = itemspritescripts[w->script];
762 // stack = &(w->scrmem->stack);
763 // ri->itemref = i;
764
765 // if (!w->initialised)
766 // {
767 // got_initialized = true;
768 // for ( int32_t q = 0; q < 8; q++ )
769 // {
770 // ri->d[q] = w->initD[q];
771 // }
772 // w->initialised = 1;
773 // }
774 // }
775 // break;
776
777 case ScriptType::Item:
778 {
779 4287 int32_t i = index;
780 4287 int32_t new_i = 0;
781
2/2
✓ Branch 0 taken 4093 times.
✓ Branch 1 taken 194 times.
4287 bool collect = ( ( i < 1 ) || (i == COLLECT_SCRIPT_ITEM_ZERO) );
782
3/4
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 4093 times.
✓ Branch 2 taken 194 times.
✗ Branch 3 not taken.
4287 new_i = ( collect ) ? (( i != COLLECT_SCRIPT_ITEM_ZERO ) ? (i * -1) : 0) : i;
783
784 4287 curscript = itemscripts[script];
785
786
2/2
✓ Branch 0 taken 3278 times.
✓ Branch 1 taken 1009 times.
4287 if (!data.initialized)
787 {
788 1009 got_initialized = true;
789
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
1009 memcpy(ri->d, ( collect ) ? itemsbuf[new_i].initiald : itemsbuf[i].initiald, 8 * sizeof(int32_t));
790
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
1009 memcpy(ri->a, ( collect ) ? itemsbuf[new_i].initiala : itemsbuf[i].initiala, 2 * sizeof(int32_t));
791 1009 data.initialized = true;
792 1009 }
793
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 4093 times.
4287 ri->idata = ( collect ) ? new_i : i; //'this' pointer
794 }
795 4287 break;
796
797 case ScriptType::Global:
798 {
799 3886494 curscript = globalscripts[script];
800 }
801 3886494 break;
802
803 // case ScriptType::Generic:
804 // {
805 // user_genscript& scr = user_scripts[script];
806 // stack = &scr.stack;
807 // ri = &scr.ri;
808 // ri->genericdataref = script;
809 // curscript = genericscripts[script];
810 // scr.waitevent = false;
811 // if(!scr.initialized)
812 // {
813 // got_initialized = true;
814 // scr.initialized = true;
815 // memcpy(ri->d, scr.initd, 8 * sizeof(int32_t));
816 // }
817 // }
818 // break;
819
820 // case ScriptType::GenericFrozen:
821 // {
822 // ri = genericActiveData.back();
823 // ri->genericdataref = script;
824 // curscript = genericscripts[script];
825 // stack = generic_active_stack.back();
826 // if(!gen_active_initialized)
827 // {
828 // got_initialized = true;
829 // gen_active_initialized = true;
830 // memcpy(ri->d, user_scripts[script].initd, 8 * sizeof(int32_t));
831 // }
832 // }
833 // break;
834
835 case ScriptType::Player:
836 {
837 271329 curscript = playerscripts[script];
838 }
839 271329 break;
840
841 case ScriptType::DMap:
842 {
843 13747 curscript = dmapscripts[script];
844 13747 ri->dmapsref = index;
845 //how do we clear initialised on dmap change?
846
2/2
✓ Branch 0 taken 13732 times.
✓ Branch 1 taken 15 times.
13747 if ( !data.initialized )
847 {
848 15 got_initialized = true;
849
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 15 times.
135 for ( int32_t q = 0; q < 8; q++ )
850 {
851 120 ri->d[q] = DMaps[ri->dmapsref].initD[q];// * 10000;
852 120 }
853 15 data.initialized = true;
854 15 }
855 }
856 13747 break;
857
858 case ScriptType::OnMap:
859 {
860 114 curscript = dmapscripts[script];
861 114 ri->dmapsref = index;
862
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 3 times.
114 if (!data.initialized)
863 {
864 3 got_initialized = true;
865
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 3 times.
27 for ( int32_t q = 0; q < 8; q++ )
866 {
867 24 ri->d[q] = DMaps[ri->dmapsref].onmap_initD[q];
868 24 }
869 3 data.initialized = true;
870 3 }
871 }
872 114 break;
873
874 case ScriptType::ActiveSubscreen:
875 {
876 12244 curscript = dmapscripts[script];
877 12244 ri->dmapsref = index;
878
2/2
✓ Branch 0 taken 12203 times.
✓ Branch 1 taken 41 times.
12244 if (!data.initialized)
879 {
880 41 got_initialized = true;
881
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 41 times.
369 for ( int32_t q = 0; q < 8; q++ )
882 {
883 328 ri->d[q] = DMaps[ri->dmapsref].sub_initD[q];
884 328 }
885 41 data.initialized = true;
886 41 }
887 }
888 12244 break;
889
890 case ScriptType::PassiveSubscreen:
891 {
892 1402 curscript = dmapscripts[script];
893 1402 ri->dmapsref = index;
894
2/2
✓ Branch 0 taken 1400 times.
✓ Branch 1 taken 2 times.
1402 if (!data.initialized)
895 {
896 2 got_initialized = true;
897
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2 times.
18 for ( int32_t q = 0; q < 8; q++ )
898 {
899 16 ri->d[q] = DMaps[ri->dmapsref].sub_initD[q];
900 16 }
901 2 data.initialized = true;
902 2 }
903 }
904 1402 break;
905
906 case ScriptType::Screen:
907 {
908 9910 curscript = screenscripts[script];
909
910
2/2
✓ Branch 0 taken 9887 times.
✓ Branch 1 taken 23 times.
9910 if (!data.initialized)
911 {
912 23 got_initialized = true;
913
2/2
✓ Branch 0 taken 184 times.
✓ Branch 1 taken 23 times.
207 for ( int32_t q = 0; q < 8; q++ )
914 {
915 184 ri->d[q] = tmpscr->screeninitd[q];// * 10000;
916 184 }
917 23 data.initialized = true;
918 23 }
919 }
920 9910 break;
921
922 case ScriptType::Combo:
923 {
924 38089 curscript = comboscripts[script];
925
926 38089 int32_t pos = combopos_ref_to_pos(index);
927 38089 int32_t lyr = combopos_ref_to_layer(index);
928 38089 int32_t id = FFCore.tempScreens[lyr]->data[pos];
929
2/2
✓ Branch 0 taken 37715 times.
✓ Branch 1 taken 374 times.
38089 if (!data.initialized)
930 {
931 374 got_initialized = true;
932 374 memset(ri->d, 0, 8 * sizeof(int32_t));
933
2/2
✓ Branch 0 taken 748 times.
✓ Branch 1 taken 374 times.
1122 for ( int32_t q = 0; q < 2; q++ )
934 748 ri->d[q] = combobuf[id].initd[q];
935 374 data.initialized = true;
936 374 }
937
938 38089 ri->combosref = id; //'this' pointer
939 38089 ri->comboposref = index; //used for X(), Y(), Layer(), and so forth.
940 38089 break;
941 }
942 }
943
944 8919074 return got_initialized;
945 }
946
947 //Sprite script data
948 refInfo npcScriptData[256];
949 refInfo lweaponScriptData[256]; //should this be lweapon and eweapon, separate stacks?
950 refInfo eweaponScriptData[256]; //should this be lweapon and eweapon, separate stacks?
951 refInfo itemactiveScriptData[256];
952
953 int32_t ffmisc[MAXFFCS][16];
954
955
3/4
✓ Branch 0 taken 59392 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59276 times.
✓ Branch 3 taken 116 times.
59392 user_genscript user_scripts[NUMSCRIPTSGENERIC];
956 int32_t genscript_timing = SCR_TIMING_START_FRAME;
957 static word max_valid_genscript;
958 static dword max_valid_object;
959
960 363 void user_genscript::quit()
961 {
962 363 doscript = false;
963
1/2
✓ Branch 0 taken 363 times.
✗ Branch 1 not taken.
363 if(indx > -1)
964 {
965 363 FFCore.deallocateAllArrays(ScriptType::Generic, indx);
966 363 }
967 363 }
968
969 529 void countGenScripts()
970 {
971 529 max_valid_genscript = 0;
972
2/2
✓ Branch 0 taken 270319 times.
✓ Branch 1 taken 529 times.
270848 for(auto q = 1; q < NUMSCRIPTSGENERIC; ++q)
973 {
974
4/4
✓ Branch 0 taken 211043 times.
✓ Branch 1 taken 59276 times.
✓ Branch 2 taken 210888 times.
✓ Branch 3 taken 155 times.
270319 if(genericscripts[q] && genericscripts[q]->valid())
975 155 max_valid_genscript = q;
976 270319 }
977 529 }
978 408 void countObjects()
979 {
980 408 max_valid_object = 0;
981
2/2
✓ Branch 0 taken 87617184 times.
✓ Branch 1 taken 408 times.
87617592 for(auto q = 0; q < MAX_USER_OBJECTS; ++q)
982 {
983
1/2
✓ Branch 0 taken 87617184 times.
✗ Branch 1 not taken.
87617184 if(script_objects[q].reserved)
984 max_valid_object = q+1;
985 87617184 }
986 408 }
987 19590 void timeExitAllGenscript(byte exState)
988 {
989
2/2
✓ Branch 0 taken 10030080 times.
✓ Branch 1 taken 19590 times.
10049670 for(user_genscript& g : user_scripts)
990 10030080 g.timeExit(exState);
991 19590 }
992 303808 void throwGenScriptEvent(int32_t event)
993 {
994
2/2
✓ Branch 0 taken 38899 times.
✓ Branch 1 taken 303808 times.
342707 for(auto q = 1; q <= max_valid_genscript; ++q)
995 {
996 38899 user_genscript& scr = user_scripts[q];
997
2/2
✓ Branch 0 taken 12956 times.
✓ Branch 1 taken 25943 times.
38899 if(!scr.doscript) continue;
998
2/2
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 3238 times.
12956 if(!genericscripts[q]->valid()) continue;
999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9718 times.
9718 if(!scr.waitevent) continue;
1000 if(scr.eventstate & (1<<event))
1001 {
1002 scr.ri.d[rEXP1] = event*10000;
1003 scr.waitevent = false;
1004
1005 //Run the script!
1006 ZScriptVersion::RunScript(ScriptType::Generic, q, q);
1007 }
1008 }
1009 303808 }
1010
1011 74 void load_genscript(const gamedata& gd)
1012 {
1013
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 74 times.
37962 for(size_t q = 0; q < NUMSCRIPTSGENERIC; ++q)
1014 {
1015 37888 user_genscript& gen = user_scripts[q];
1016 37888 gen.clear();
1017 37888 gen.indx = q;
1018 37888 gen.doscript = gd.gen_doscript[q];
1019 37888 gen.exitState = gd.gen_exitState[q];
1020 37888 gen.reloadState = gd.gen_reloadState[q];
1021 37888 gen.eventstate = gd.gen_eventstate[q];
1022 37888 memcpy(gen.initd, gd.gen_initd[q], sizeof(gen.initd));
1023 37888 gen.data = gd.gen_data[q];
1024 37888 gen.dataResize(gd.gen_dataSize[q]);
1025 37888 }
1026 74 }
1027 47 void load_genscript(const zinitdata& zd)
1028 {
1029
2/2
✓ Branch 0 taken 24064 times.
✓ Branch 1 taken 47 times.
24111 for(size_t q = 0; q < NUMSCRIPTSGENERIC; ++q)
1030 {
1031 24064 user_genscript& gen = user_scripts[q];
1032 24064 gen.clear();
1033 24064 gen.indx = q;
1034 24064 gen.doscript = zd.gen_doscript[q];
1035 24064 gen.exitState = zd.gen_exitState[q];
1036 24064 gen.reloadState = zd.gen_reloadState[q];
1037 24064 gen.eventstate = zd.gen_eventstate[q];
1038 24064 memcpy(gen.initd, zd.gen_initd[q], sizeof(gen.initd));
1039 24064 gen.dataResize(zd.gen_data[q].size());
1040 24064 gen.data = zd.gen_data[q];
1041 24064 gen.dataResize(zd.gen_dataSize[q]);
1042 24064 }
1043 47 }
1044
1045 void save_genscript(gamedata& gd)
1046 {
1047 for(size_t q = 0; q < NUMSCRIPTSGENERIC; ++q)
1048 {
1049 user_genscript const& gen = user_scripts[q];
1050 gd.gen_doscript[q] = gen.doscript;
1051 gd.gen_exitState[q] = gen.exitState;
1052 gd.gen_reloadState[q] = gen.reloadState;
1053 gd.gen_eventstate[q] = gen.eventstate;
1054 memcpy(gd.gen_initd[q], gen.initd, sizeof(gen.initd));
1055 gd.gen_dataSize[q] = gen.dataSize();
1056 gd.gen_data[q] = gen.data;
1057 }
1058 }
1059
1060 300419154 void FFScript::runGenericPassiveEngine(int32_t scrtm)
1061 {
1062
2/2
✓ Branch 0 taken 3488905 times.
✓ Branch 1 taken 296930249 times.
300419154 if(!max_valid_genscript) return; //No generic scripts in the quest!
1063 //zprint2("Processing timing %d\n", scrtm);
1064 3488905 bool init = (scrtm == SCR_TIMING_INIT);
1065
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3488903 times.
3488905 if(!init)
1066 {
1067
2/2
✓ Branch 0 taken 22439 times.
✓ Branch 1 taken 3466464 times.
3488903 if(genscript_timing != scrtm)
1068 {
1069 //zprint2("Generic script timing jump: expected '%d', found '%d'\n", genscript_timing, scrtm);
1070
2/2
✓ Branch 0 taken 78875 times.
✓ Branch 1 taken 22439 times.
101314 while(genscript_timing != scrtm)
1071 78875 runGenericPassiveEngine(genscript_timing);
1072 22439 }
1073 3488903 }
1074
2/2
✓ Branch 0 taken 41557265 times.
✓ Branch 1 taken 3488905 times.
45046170 for(auto q = 1; q <= max_valid_genscript; ++q)
1075 {
1076 41557265 user_genscript& scr = user_scripts[q];
1077
2/2
✓ Branch 0 taken 13843030 times.
✓ Branch 1 taken 27714235 times.
41557265 if(!scr.doscript) continue;
1078
2/2
✓ Branch 0 taken 10382275 times.
✓ Branch 1 taken 3460755 times.
13843030 if(!genericscripts[q]->valid()) continue;
1079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10382275 times.
10382275 if(scr.waitevent) continue;
1080
8/8
✓ Branch 0 taken 10382273 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 10204736 times.
✓ Branch 3 taken 177537 times.
✓ Branch 4 taken 10204389 times.
✓ Branch 5 taken 347 times.
✓ Branch 6 taken 9760653 times.
✓ Branch 7 taken 443736 times.
10382275 if(!init && (scr.waituntil > scrtm || (!scr.wait_atleast && scr.waituntil != scrtm)))
1081 9938190 continue;
1082
1083 //Run the script!
1084 444085 ZScriptVersion::RunScript(ScriptType::Generic, q, q);
1085 444085 }
1086
4/4
✓ Branch 0 taken 3488903 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3399462 times.
✓ Branch 3 taken 89441 times.
3488905 if(init || genscript_timing >= SCR_TIMING_END_FRAME)
1087 89443 genscript_timing = SCR_TIMING_START_FRAME;
1088 3399462 else ++genscript_timing;
1089 300419154 }
1090
1091 5238 void FFScript::initZScriptDMapScripts()
1092 {
1093 5238 scriptEngineDatas[{ScriptType::DMap, 0}] = ScriptEngineData();
1094 5238 scriptEngineDatas[{ScriptType::PassiveSubscreen, 0}] = ScriptEngineData();
1095 5238 }
1096
1097 5263 void FFScript::initZScriptActiveSubscreenScript()
1098 {
1099 5263 scriptEngineDatas[{ScriptType::ActiveSubscreen, 0}] = ScriptEngineData();
1100 5263 }
1101
1102 3 void FFScript::initZScriptOnMapScript()
1103 {
1104 3 scriptEngineDatas[{ScriptType::OnMap, 0}] = ScriptEngineData();
1105 3 }
1106
1107 965 void FFScript::initZScriptHeroScripts()
1108 {
1109 965 scriptEngineDatas[{ScriptType::Player, 0}] = ScriptEngineData();
1110 965 }
1111
1112 904 void FFScript::initZScriptItemScripts()
1113 {
1114
2/2
✓ Branch 0 taken 231424 times.
✓ Branch 1 taken 904 times.
232328 for ( int32_t q = 0; q < 256; q++ )
1115 {
1116 231424 auto& data = get_script_engine_data(ScriptType::Item, q);
1117 231424 data.reset();
1118
2/2
✓ Branch 0 taken 231422 times.
✓ Branch 1 taken 2 times.
231424 data.doscript = (itemsbuf[q].flags&ITEM_PASSIVESCRIPT) && game->item[q];
1119 231424 }
1120
1121
2/2
✓ Branch 0 taken 231424 times.
✓ Branch 1 taken 904 times.
232328 for ( int32_t q = -256; q < 0; q++ )
1122 {
1123 231424 auto& data = get_script_engine_data(ScriptType::Item, q);
1124 231424 data.reset();
1125 231424 data.doscript = 0;
1126 231424 }
1127 904 }
1128
1129 2574844 static int get_mouse_state(int index)
1130 {
1131 2574844 int value = 0;
1132
1/2
✓ Branch 0 taken 2574844 times.
✗ Branch 1 not taken.
2574844 if (replay_is_replaying())
1133 {
1134 2574844 value = replay_get_mouse(index);
1135 2574844 }
1136 else if (index == 0)
1137 {
1138 value = script_mouse_x;
1139 }
1140 else if (index == 1)
1141 {
1142 value = script_mouse_y;
1143 }
1144 else if (index == 2)
1145 {
1146 value = script_mouse_z;
1147 }
1148 else if (index == 3)
1149 {
1150 value = script_mouse_b;
1151 }
1152
1153
1/2
✓ Branch 0 taken 2574844 times.
✗ Branch 1 not taken.
2574844 if (replay_is_recording())
1154 {
1155 replay_set_mouse(index, value);
1156 }
1157
1158 2574844 return value;
1159 }
1160
1161 ///----------------------------------------------//
1162 // New Mapscreen Flags Tools //
1163 ///----------------------------------------------//
1164
1165 /*
1166 void FFScript::set_mapscreenflag_state(mapscr *m, int32_t flagid, bool state)
1167 {
1168 switch(flagid)
1169 {
1170 // Room Types
1171 case MSF_INTERIOR:
1172 if ( state )
1173 m->flags6 |= 1;
1174 else m->flags6 &= ~1;
1175 break;
1176 case MSF_DUNGEON:
1177 if ( state )
1178 m->flags6 |= 2;
1179 else m->flags6 &= ~2;
1180 break;
1181 case MSF_SIDEVIEW:
1182 if ( state )
1183 m->flags7 |= 8;
1184 else m->flags7 &= ~8;
1185 break;
1186
1187 // View
1188 case MSF_INVISHERO:
1189 if ( state )
1190 m->flags3 |= 8;
1191 else m->flags3 &= ~8;
1192 break;
1193 case MSF_NOHEROMARKER:
1194 if ( state )
1195 m->flags7 |= 16;
1196 else m->flags7 &= ~16;
1197 break;
1198
1199 case MSF_NOSUBSCREEN:
1200 if ( state )
1201 m->flags3 |= 16;
1202 else m->flags3 &= ~16;
1203 break;
1204 case MSF_NOOFFSET:
1205 if ( state )
1206 m->flags3 |= 64;
1207 else m->flags3 &= ~64;
1208 break;
1209
1210 case MSF_LAYER2BG:
1211 if ( state )
1212 m->flags7 |= 2;
1213 else m->flags7 &= ~2;
1214 break;
1215 case MSF_LAYER3BG:
1216 if ( state )
1217 m->flags7 |= 1;
1218 else m->flags7 &= ~1;
1219 break;
1220 case MSF_DARKROOM:
1221 if ( state )
1222 m->flags |= 4;
1223 else m->flags &= ~4;
1224 break;
1225
1226 // Secrets
1227 case MSF_BLOCKSHUT:
1228 if ( state )
1229 m->flags |= 1;
1230 else m->flags &= ~1;
1231 break;
1232 case MSF_TEMPSECRETS:
1233 if ( state )
1234 m->flags5 |= 16;
1235 else m->flags5 &= ~16;
1236 break;
1237
1238 case MSF_TRIGPERM:
1239 if ( state )
1240 m->flags6 |= 4;
1241 else m->flags6 &= ~4;
1242 break;
1243 case MSF_ALLTRIGFLAGS:
1244 if ( state )
1245 m->flags6 |= 32;
1246 else m->flags6 &= ~32;
1247 break;
1248 // Warp
1249 case MSF_AUTODIRECT:
1250 if ( state )
1251 m->flags5 |= 4;
1252 else m->flags5 &= ~4;
1253 break;
1254 case MSF_SENDSIRECT:
1255 if ( state )
1256 m->flags5 |= 8;
1257 else m->flags5 &= ~8;
1258 break;
1259 case MSF_MAZEPATHS:
1260 if ( state )
1261 m->flags |= 64;
1262 else m->flags &= ~64;
1263 break;
1264
1265 case MSF_MAZEOVERRIDE:
1266 if ( state )
1267 m->flags8 |= 64;
1268 else m->flags8 &= ~64;
1269 break;
1270 case MSF_SPRITECARRY:
1271 if ( state )
1272 m->flags3 |= 32;
1273 else m->flags3 &= ~32;
1274 break;
1275
1276 case MSF_DIRECTTIMEDWARPS:
1277 if ( state )
1278 m->flags4 |= 4;
1279 else m->flags4 &= ~4;
1280 break;
1281
1282 case MSF_SECRETSISABLETIMEWRP:
1283 if ( state )
1284 m->flags4 |= 8;
1285 else m->flags4 &= ~8;
1286 break;
1287 case MSF_RANDOMTIMEDWARP:
1288 if ( state )
1289 m->flags5 |= 1;
1290 else m->flags5 &= ~1;
1291 break;
1292
1293 // Item
1294 case MSF_HOLDUP:
1295 if ( state )
1296 m->flags3 |= 1;
1297 else m->flags3 &= ~1;
1298 break;
1299
1300 case MSF_FALLS:
1301 if ( state )
1302 m->flags7 |= 4;
1303 else m->flags7 &= ~4;
1304 break;
1305
1306
1307 // Combo
1308 case MSF_MIDAIR:
1309 { //FIX ME!
1310 //! What the ever love of fuck mate?!
1311 // byte *f2 = &(m->flags2);
1312 // f2 >>=4;
1313 // int32_t f = 0;
1314 // f<<=1;
1315 // f |= state ? 1:0;
1316 // m->flags2 &= 0x0F;
1317 // m->flags2 |= f<<4;
1318 //if ( state )
1319 // (m->flags2>>4) |= 2;
1320 //else (m->flags2>>4) &= ~2;
1321 break;
1322 }
1323 case MSF_CYCLEINIT:
1324 if ( state )
1325 m->flags3 |= 2;
1326 else m->flags3 &= ~2;
1327 break;
1328 case MSF_IGNOREBOOTS:
1329 if ( state )
1330 m->flags5 |= 2;
1331 else m->flags5 &= ~2;
1332 break;
1333 case MSF_TOGGLERINGS:
1334 if ( state )
1335 m->flags6 |= 64;
1336 else m->flags6 &= ~64;
1337 break;
1338 // Save
1339 case MSF_SAVECONTHERE:
1340 if ( state )
1341 m->flags4 |= 64;
1342 else m->flags4 &= ~64;
1343 break;
1344 case MSF_SAVEONENTRY:
1345 if ( state )
1346 m->flags4 |= 128;
1347 else m->flags4 &= ~128;
1348 break;
1349
1350 case MSF_CONTHERE:
1351 if ( state )
1352 m->flags6 |= 8;
1353 else m->flags6 &= ~8;
1354 break;
1355
1356 case MSF_NOCONTINUEWARP:
1357 if ( state )
1358 m->flags6 |= 16;
1359 else m->flags6 &= ~16;
1360 break;
1361
1362 // FFC
1363 case MSF_WRAPFFC:
1364 if ( state )
1365 m->flags6 |= 128;
1366 else m->flags6 &= ~128;
1367 break;
1368
1369 case MSF_NOCARRYOVERFFC:
1370 if ( state )
1371 m->flags5 |= 128;
1372 else m->flags5 &= ~128;
1373 break;
1374
1375 // Whistle
1376 case MSF_STAIRS:
1377 if ( state )
1378 m->flags |= 16;
1379 else m->flags &= ~16;
1380 break;
1381 case MSF_PALCHANGE:
1382 if ( state )
1383 m->flags7 |= 64;
1384 else m->flags7 &= ~64;
1385 break;
1386 case MSF_DRYLAKE:
1387 if ( state )
1388 m->flags7 |= 128;
1389 else m->flags7 &= ~128;
1390 break;
1391
1392 // Enemies
1393 case MSF_TRAPS_IGNORE_SOLID:
1394 {
1395 //! What the ever love of fuck mate?!
1396 int32_t f = 0;
1397 f<<=2;
1398 f |= state ? 1:0;
1399 m->flags2 &= 0x0F;
1400 m->flags2 |= f<<4;
1401 break;
1402
1403 //! May be wrong : Might be 4>>4 : ~4>>4;?
1404 //if ( state )
1405 // m->(flags2>>4) |= 4;
1406 //else (flags2>>4) &= ~4;
1407 //break;
1408 }
1409 case MSF_ENEMEIS_SECRET:
1410 {
1411 //! What the ever love of fuck mate?!
1412 int32_t f = 0;
1413 f<<=3;
1414 f |= state ? 1:0;
1415 m->flags2 &= 0x0F;
1416 m->flags2 |= f<<4;
1417 break;
1418
1419 //! May be wrong : Might be 8>>4 : ~8>>4;?
1420 //if ( state )
1421 // m->(flags2>>4) |= 8;
1422 //else (flags2>>4) &= ~8;
1423 //break;
1424 }
1425 case MSF_INVISIBLEENEMIES:
1426 if ( state )
1427 m->flags3 |= 4;
1428 else m->flags3 &= ~4;
1429 case MSF_EMELIESALWAYSRETURN:
1430 if ( state )
1431 m->flags3 |= 128;
1432 else m->flags3 &= ~128;
1433 break;
1434 case MSF_ENEMIES_ITEM:
1435 if ( state )
1436 m->flags |= 2;
1437 else m->flags &= ~2;
1438 break;
1439
1440 case MSF_ENEMIES_SECRET_PERM:
1441 if ( state )
1442 m->flags4 |= 16;
1443 else m->flags4 &= ~16;
1444 break;
1445
1446 case MSF_SPAWN_ZORA:
1447 if ( state )
1448 m->enemyflags |= 1;
1449 else m->enemyflags &= ~1;
1450 break;
1451 case MSF_SPAWN_CORNERTRAP:
1452 if ( state )
1453 m->enemyflags |= 2;
1454 else m->enemyflags &= ~2;
1455 break;
1456 case MSF_SPAWN_MIDDLETRAP:
1457 if ( state )
1458 m->enemyflags |= 4;
1459 else m->enemyflags &= ~4;
1460 break;
1461 case MSF_SPAWN_ROCK:
1462 if ( state )
1463 m->enemyflags |= 8;
1464 else m->enemyflags &= ~8;
1465 break;
1466 case MSF_SPAWN_SHOOTER:
1467 if ( state )
1468 m->enemyflags |= 16;
1469 else m->enemyflags &= ~16;
1470 break;
1471
1472 case MSF_RINGLEADER:
1473 if ( state )
1474 m->enemyflags |= 32;
1475 else m->enemyflags &= ~32;
1476 break;
1477 case MSF_ENEMYHASITEM:
1478 if ( state )
1479 m->enemyflags |= 64;
1480 else m->enemyflags &= ~64;
1481 break;
1482 case MSF_ENEMYISBOSS:
1483 if ( state )
1484 m->enemyflags |= 128;
1485 else m->enemyflags &= ~128;
1486 break;
1487
1488 // Misc
1489 case MSF_ALLOW_LADDER:
1490 if ( state )
1491 m->flags |= 32;
1492 else m->flags &= ~32;
1493 break;
1494 case MSF_NO_DIVING:
1495 if ( state )
1496 m->flags5 |= 64;
1497 else m->flags5 &= ~64;
1498 break;
1499
1500 case MSF_LENSEFFECT:
1501 if ( state )
1502 m->flags8 |= 32;
1503 else m->flags8 &= ~32;
1504 break;
1505
1506 case MSF_SFXONENTRY:
1507 if ( state )
1508 m->flags |= 128;
1509 else m->flags &= ~128;
1510 break;
1511
1512
1513 // Custom / Script
1514 case MSF_SCRIPT1:
1515 if ( state )
1516 m->flags8 |= 1;
1517 else m->flags8 &= ~1;
1518 break;
1519 case MSF_SCRIPT2:
1520 if ( state )
1521 m->flags8 |= 2;
1522 else m->flags8 &= ~2;
1523 break;
1524 case MSF_SCRIPT3:
1525 if ( state )
1526 m->flags8 |= 4;
1527 else m->flags8 &= ~4;
1528 break;
1529 case MSF_SCRIPT4:
1530 if ( state )
1531 m->flags8 |= 8;
1532 else m->flags8 &= ~8;
1533 break;
1534 case MSF_SCRIPT5:
1535 if ( state )
1536 m->flags8 |= 16;
1537 else m->flags8 &= ~16;
1538 break;
1539
1540 //This is a dummy proc, but may have been used at one point in older versions.
1541 case MSF_DUMMY_8:
1542 if ( state )
1543 m->flags |= 8;
1544 else m->flags &= ~8;
1545 break;
1546
1547 default: Z_scripterrlog("Illegal flag value (%d) passed to SetMapscreenFlag", flagid);
1548 }
1549 }
1550
1551 int32_t FFScript::get_mapscreenflag_state(mapscr *m, int32_t flagid)
1552 {
1553 switch(flagid)
1554 {
1555 // Room Types
1556 case MSF_INTERIOR:
1557 return (m->flags6&1) ? 1 : 0;
1558 case MSF_DUNGEON:
1559 return (m->flags6&2) ? 1 : 0;
1560 case MSF_SIDEVIEW:
1561 return (m->flags7&8) ? 1 : 0;
1562
1563 // View
1564 case MSF_INVISHERO:
1565 return (m->flags3&8) ? 1 : 0;
1566 case MSF_NOHEROMARKER:
1567 return (m->flags7&16) ? 1 : 0;
1568
1569 case MSF_NOSUBSCREEN:
1570 return (m->flags3&16) ? 1 : 0;
1571 case MSF_NOOFFSET:
1572 return (m->flags3&64) ? 1 : 0;
1573
1574 case MSF_LAYER2BG:
1575 return (m->flags7&2) ? 1 : 0;
1576 case MSF_LAYER3BG:
1577 return (m->flags7&1) ? 1 : 0;
1578 case MSF_DARKROOM:
1579 return (m->flags&4) ? 1 : 0;
1580
1581 // Secrets
1582 case MSF_BLOCKSHUT:
1583 return (m->flags&1) ? 1 : 0;
1584 case MSF_TEMPSECRETS:
1585 return (m->flags5&16) ? 1 : 0;
1586 case MSF_TRIGPERM:
1587 return (m->flags6&4) ? 1 : 0;
1588 case MSF_ALLTRIGFLAGS:
1589 return (m->flags6&32) ? 1 : 0;
1590
1591 // Warp
1592 case MSF_AUTODIRECT:
1593 return (m->flags5&4) ? 1 : 0;
1594 case MSF_SENDSIRECT:
1595 return (m->flags5&8) ? 1 : 0;
1596 case MSF_MAZEPATHS:
1597 return (m->flags&64) ? 1 : 0;
1598
1599 case MSF_MAZEOVERRIDE:
1600 return (m->flags8&64) ? 1 : 0;
1601 case MSF_SPRITECARRY:
1602 return (m->flags3&32) ? 1 : 0;
1603 case MSF_DIRECTTIMEDWARPS:
1604 return (m->flags4&4) ? 1 : 0;
1605 case MSF_SECRETSISABLETIMEWRP:
1606 return (m->flags4&8) ? 1 : 0;
1607
1608 case MSF_RANDOMTIMEDWARP:
1609 return (m->flags5&1) ? 1 : 0;
1610
1611 // Item
1612 case MSF_HOLDUP:
1613 return (m->flags3&1) ? 1 : 0;
1614 case MSF_FALLS:
1615 return (m->flags7&4) ? 1 : 0;
1616
1617 // Combo
1618 case MSF_MIDAIR:
1619 return ((m->flags2>>4)&2) ? 1 : 0;
1620 case MSF_CYCLEINIT:
1621 return (m->flags3&2) ? 1 : 0;
1622 case MSF_IGNOREBOOTS:
1623 return (m->flags5&2) ? 1 : 0;
1624 case MSF_TOGGLERINGS:
1625 return (m->flags6&64) ? 1 : 0;
1626 // Save
1627 case MSF_SAVECONTHERE:
1628 return (m->flags4&64) ? 1 : 0;
1629 case MSF_SAVEONENTRY:
1630 return (m->flags4&128) ? 1 : 0;
1631
1632 case MSF_CONTHERE:
1633 return (m->flags6&8) ? 1 : 0;
1634
1635 case MSF_NOCONTINUEWARP:
1636 return (m->flags6&16) ? 1 : 0;
1637
1638 // FFC
1639 case MSF_WRAPFFC:
1640 return (m->flags6&128) ? 1 : 0;
1641
1642 case MSF_NOCARRYOVERFFC:
1643 return (m->flags5&128) ? 1 : 0;
1644
1645 // Whistle
1646 case MSF_STAIRS:
1647 return (m->flags&16) ? 1 : 0;
1648 case MSF_PALCHANGE:
1649 return (m->flags7&64) ? 1 : 0;
1650 case MSF_DRYLAKE:
1651 return (m->flags7&128) ? 1 : 0;
1652
1653 // Enemies
1654 case MSF_TRAPS_IGNORE_SOLID:
1655 //! May be wrong : Might be 4>>4 : ~4>>4;?
1656 return ((m->flags2>>4)&4) ? 1 : 0;
1657
1658 case MSF_ENEMEIS_SECRET:
1659 //! May be wrong : Might be 8>>4 : ~8>>4;?
1660 return ((m->flags2>>4)&8) ? 1 : 0;
1661
1662 case MSF_ENEMIES_SECRET_PERM:
1663 return (m->flags4&16) ? 1 : 0;
1664
1665 case MSF_SPAWN_ZORA:
1666 return (m->enemyflags&1) ? 1 : 0;
1667
1668 case MSF_SPAWN_CORNERTRAP:
1669 return (m->enemyflags&2) ? 1 : 0;
1670
1671 case MSF_SPAWN_MIDDLETRAP:
1672 return (m->enemyflags&3) ? 1 : 0;
1673
1674 case MSF_SPAWN_ROCK:
1675 return (m->enemyflags&4) ? 1 : 0;
1676
1677 case MSF_SPAWN_SHOOTER:
1678 return (m->enemyflags&16) ? 1 : 0;
1679
1680 case MSF_RINGLEADER:
1681 return (m->enemyflags&32) ? 1 : 0;
1682
1683 case MSF_ENEMYHASITEM:
1684 return (m->enemyflags&64) ? 1 : 0;
1685 case MSF_ENEMYISBOSS:
1686 return (m->enemyflags&128) ? 1 : 0;
1687
1688 case MSF_INVISIBLEENEMIES:
1689 return (m->flags3&4) ? 1 : 0;
1690 case MSF_EMELIESALWAYSRETURN:
1691 return (m->flags3&128) ? 1 : 0;
1692
1693 case MSF_ENEMIES_ITEM:
1694 return (m->flags&2) ? 1 : 0;
1695
1696 // Misc
1697 case MSF_ALLOW_LADDER:
1698 return (m->flags&32) ? 1 : 0;
1699 case MSF_NO_DIVING:
1700 return (m->flags5&64) ? 1 : 0;
1701
1702 case MSF_LENSEFFECT:
1703 return (m->flags8&32) ? 1 : 0;
1704
1705 case MSF_SFXONENTRY:
1706 return (m->flags&128) ? 1 : 0;
1707
1708 //Custom / Script
1709 case MSF_SCRIPT1:
1710 return (m->flags8&1) ? 1 : 0;
1711 case MSF_SCRIPT2:
1712 return (m->flags8&2) ? 1 : 0;
1713 case MSF_SCRIPT3:
1714 return (m->flags8&4) ? 1 : 0;
1715 case MSF_SCRIPT4:
1716 return (m->flags8&8) ? 1 : 0;
1717 case MSF_SCRIPT5:
1718 return (m->flags8&16) ? 1 : 0;
1719
1720 //This is a dummy proc, but may have been used at one point in older versions.
1721 case MSF_DUMMY_8:
1722 return (m->flags&8) ? 1 : 0;
1723
1724
1725 default:
1726 {
1727 Z_scripterrlog("Illegal flag value (%d) passed to GetMapscreenFlag", flagid);
1728 return -1;
1729 }
1730 }
1731 }
1732 */
1733 //ScriptHelper
1734 class SH
1735 {
1736
1737 ///-----------------------------//
1738 // Errors //
1739 ///-----------------------------//
1740
1741 public:
1742
1743 enum __Error
1744 {
1745 _NoError, //OK!
1746 _Overflow, //script array too small
1747 _InvalidPointer, //passed NULL pointer or similar
1748 _OutOfBounds, //library array out of bounds
1749 _InvalidSpriteUID //bad npc, ffc, etc.
1750 };
1751
1752 #define INVALIDARRAY localRAM[0] //localRAM[0] is never used
1753
1754 //only if the player is messing with their pointers...
1755 static ZScriptArray& InvalidError(const int32_t ptr)
1756 {
1757 Z_scripterrlog("Invalid pointer (%i) passed to array (don't change the values of your array pointers)\n", ptr);
1758 return INVALIDARRAY;
1759 }
1760
1761 static void write_stack(const uint32_t stackoffset, const int32_t value)
1762 {
1763 if(stackoffset == 0)
1764 {
1765 Z_scripterrlog("Stack over or underflow, stack pointer = %ld\n", stackoffset);
1766 return;
1767 }
1768
1769 (*stack)[stackoffset] = value;
1770 }
1771
1772 305897352 static int32_t read_stack(const uint32_t stackoffset)
1773 {
1774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 305897352 times.
305897352 if(stackoffset == 0)
1775 {
1776 Z_scripterrlog("Stack over or underflow, stack pointer = %ld\n", stackoffset);
1777 return -10000;
1778 }
1779
1780 305897352 return (*stack)[stackoffset];
1781 305897352 }
1782
1783 391834121 static INLINE int32_t get_arg(int32_t arg, bool v)
1784 {
1785
2/2
✓ Branch 0 taken 67833753 times.
✓ Branch 1 taken 324000368 times.
391834121 return v ? arg : get_register(arg);
1786 }
1787 };
1788
1789 ///----------------------------//
1790 // Misc. //
1791 ///----------------------------//
1792
1793 //Miscellaneous Helper
1794 class MiscH : public SH
1795 {
1796 public:
1797
1798 };
1799
1800 byte flagpos;
1801 int32_t flagval;
1802 11830527 void clear_ornextflag()
1803 {
1804 11830527 flagpos = 0;
1805 11830527 flagval = 0;
1806 11830527 }
1807 77358070 void ornextflag(bool flag)
1808 {
1809
2/2
✓ Branch 0 taken 75890978 times.
✓ Branch 1 taken 1467092 times.
77358070 if(flag) flagval |= 1<<flagpos;
1810 77358070 ++flagpos;
1811 77358070 }
1812
1813 6637837 int32_t get_screenflags(mapscr *m, int32_t flagset)
1814 {
1815 6637837 clear_ornextflag();
1816
1817
3/11
✓ Branch 0 taken 3733099 times.
✓ Branch 1 taken 2815129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 89609 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
6637837 switch(flagset)
1818 {
1819 case 0: // Room Type
1820 3733099 ornextflag(m->flags6&1);
1821 3733099 ornextflag(m->flags6&2);
1822 3733099 ornextflag(m->flags7&8);
1823 3733099 break;
1824
1825 case 1: // View
1826 2815129 ornextflag(m->flags3&8);
1827 2815129 ornextflag(m->flags7&16);
1828 2815129 ornextflag(m->flags3&16);
1829 2815129 ornextflag(m->flags3&64);
1830 2815129 ornextflag(m->flags7&2);
1831 2815129 ornextflag(m->flags7&1);
1832 2815129 ornextflag(m->flags&fDARK);
1833 2815129 ornextflag(m->flags9&fDARK_DITHER);
1834 2815129 ornextflag(m->flags9&fDARK_TRANS);
1835 2815129 break;
1836
1837 case 2: // Secrets
1838 ornextflag(m->flags&1);
1839 ornextflag(m->flags5&16);
1840 ornextflag(m->flags6&4);
1841 ornextflag(m->flags6&32);
1842 break;
1843
1844 case 3: // Warp
1845 ornextflag(m->flags5&4);
1846 ornextflag(m->flags5&8);
1847 ornextflag(m->flags&64);
1848 ornextflag(m->flags8&64);
1849 ornextflag(m->flags3&32);
1850 ornextflag(m->flags9&fDISABLE_MIRROR);
1851 break;
1852
1853 case 4: // Item
1854 ornextflag(m->flags3&1);
1855 ornextflag(m->flags7&4);
1856 ornextflag(m->flags8&0x40);
1857 ornextflag(m->flags8&0x80);
1858 ornextflag(m->flags9&0x01);
1859 ornextflag(m->flags9&0x02);
1860 ornextflag(m->flags9&0x04);
1861 break;
1862
1863 case 5: // Combo
1864 ornextflag((m->flags2>>4)&2);
1865 ornextflag(m->flags3&2);
1866 ornextflag(m->flags5&2);
1867 ornextflag(m->flags6&64);
1868 break;
1869
1870 case 6: // Save
1871 ornextflag(m->flags4&64);
1872 ornextflag(m->flags4&128);
1873 ornextflag(m->flags6&8);
1874 ornextflag(m->flags6&16);
1875 break;
1876
1877 case 7: // FFC
1878 ornextflag(m->flags6&128);
1879 ornextflag(m->flags5&128);
1880 break;
1881
1882 case 8: // Whistle
1883 ornextflag(m->flags&16);
1884 ornextflag(m->flags7&64);
1885 ornextflag(m->flags7&128);
1886 break;
1887
1888 case 9: // Misc
1889 89609 ornextflag(m->flags&32);
1890 89609 ornextflag(m->flags5&64);
1891 89609 flagval |= m->flags8<<2;
1892 89609 break;
1893 }
1894
1895 6637837 return flagval*10000;
1896 }
1897
1898 1522704 int32_t get_screeneflags(mapscr *m, int32_t flagset)
1899 {
1900 1522704 clear_ornextflag();
1901
1902
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1522704 times.
✗ Branch 3 not taken.
1522704 switch(flagset)
1903 {
1904 case 0:
1905 flagval |= m->enemyflags&0x1F;
1906 break;
1907
1908 case 1:
1909 1522704 ornextflag(m->enemyflags&32);
1910 1522704 ornextflag(m->enemyflags&64);
1911 1522704 ornextflag(m->flags3&4);
1912 1522704 ornextflag(m->enemyflags&128);
1913 1522704 ornextflag((m->flags2>>4)&4);
1914 1522704 break;
1915
1916 case 2:
1917 ornextflag(m->flags3&128);
1918 ornextflag(m->flags&2);
1919 ornextflag((m->flags2>>4)&8);
1920 ornextflag(m->flags4&16);
1921 ornextflag(m->flags9&fENEMY_WAVES);
1922 break;
1923 }
1924
1925 1522704 return flagval*10000;
1926 }
1927
1928 1263407 int32_t get_mi(int32_t ref)
1929 {
1930
2/2
✓ Branch 0 taken 45056 times.
✓ Branch 1 taken 1218351 times.
1263407 if(ref >= 0)
1931 45056 return ref - (8*(ref / MAPSCRS));
1932
1/3
✓ Branch 0 taken 1218351 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
1218351 switch(ref)
1933 {
1934 case MAPSCR_TEMP0: case MAPSCR_TEMP1: case MAPSCR_TEMP2: case MAPSCR_TEMP3:
1935 case MAPSCR_TEMP4: case MAPSCR_TEMP5: case MAPSCR_TEMP6:
1936 1218351 return (currmap*MAPSCRSNORMAL)+homescr;
1937 case MAPSCR_SCROLL0: case MAPSCR_SCROLL1: case MAPSCR_SCROLL2: case MAPSCR_SCROLL3:
1938 case MAPSCR_SCROLL4: case MAPSCR_SCROLL5: case MAPSCR_SCROLL6:
1939 return (scrolling_map*MAPSCRSNORMAL)+scrolling_scr;
1940 }
1941 return -1;
1942 1263407 }
1943
1944 ///------------------------------------------------//
1945 // Bounds Checking Functions //
1946 ///------------------------------------------------//
1947
1948 //Bounds Checker
1949 class BC : public SH
1950 {
1951 public:
1952
1953 18740053 static INLINE int32_t checkMapID(const int32_t ID, const char * const str)
1954 {
1955 //return checkBounds(ID, 0, map_count-1, str);
1956
2/4
✓ Branch 0 taken 18740053 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18740053 times.
18740053 if(ID < 0 || ID > map_count-1)
1957 {
1958 Z_scripterrlog("Invalid value (%i) passed to '%s'\n", ID+1, str);
1959 return _OutOfBounds;
1960 }
1961
1962 18740053 return _NoError;
1963 18740053 }
1964
1965 2873569 static INLINE int32_t checkDMapID(const int32_t ID, const char * const str)
1966 {
1967 2873569 return checkBounds(ID, 0, MAXDMAPS-1, str);
1968 }
1969
1970 81862333 static INLINE int32_t checkComboPos(const int32_t pos, const char * const str)
1971 {
1972 81862333 return checkBoundsPos(pos, 0, 175, str);
1973 }
1974
1975 127663 static INLINE int32_t checkTile(const int32_t pos, const char * const str)
1976 {
1977 127663 return checkBounds(pos, 0, NEWMAXTILES-1, str);
1978 }
1979
1980 2564 static INLINE int32_t checkCombo(const int32_t pos, const char * const str)
1981 {
1982 2564 return checkBounds(pos, 0, MAXCOMBOS-1, str);
1983 }
1984
1985 6076 static INLINE int32_t checkMisc(const int32_t a, const char * const str)
1986 {
1987 6076 return checkBounds(a, 0, 15, str);
1988 }
1989
1990 13992744 static INLINE int32_t checkMisc32(const int32_t a, const char * const str)
1991 {
1992 13992744 return checkBounds(a, 0, 31, str);
1993 }
1994
1995 3839 static INLINE int32_t checkMessage(const int32_t ID, const char * const str)
1996 {
1997 3839 return checkBounds(ID, 0, msg_strings_size-1, str);
1998 }
1999
2000 static INLINE int32_t checkLayer(const int32_t layer, const char * const str)
2001 {
2002 return checkBounds(layer, 0, 6, str);
2003 }
2004
2005 503793138 static INLINE int32_t checkFFC(const int32_t ffc, const char * const str)
2006 {
2007 503793138 return checkBounds(ffc, 0, MAXFFCS-1, str);
2008 }
2009
2010 15641785 static INLINE int32_t checkGuyIndex(const int32_t index, const char * const str)
2011 {
2012 15641785 return checkBoundsOneIndexed(index, 0, guys.Count()-1, str);
2013 }
2014
2015 136832 static INLINE int32_t checkItemIndex(const int32_t index, const char * const str)
2016 {
2017 136832 return checkBoundsOneIndexed(index, 0, items.Count()-1, str);
2018 }
2019
2020 2753647 static INLINE int32_t checkEWeaponIndex(const int32_t index, const char * const str)
2021 {
2022 2753647 return checkBoundsOneIndexed(index, 0, Ewpns.Count()-1, str);
2023 }
2024
2025 1201098 static INLINE int32_t checkLWeaponIndex(const int32_t index, const char * const str)
2026 {
2027 1201098 return checkBoundsOneIndexed(index, 0, Lwpns.Count()-1, str);
2028 }
2029
2030 2363 static INLINE int32_t checkGuyID(const int32_t ID, const char * const str)
2031 {
2032 //return checkBounds(ID, 0, MAXGUYS-1, str); //Can't create NPC ID 0
2033 2363 return checkBounds(ID, 1, MAXGUYS-1, str);
2034 }
2035
2036 1838278 static INLINE int32_t checkItemID(const int32_t ID, const char * const str)
2037 {
2038 1838278 return checkBounds(ID, 0, MAXITEMS-1, str);
2039 }
2040
2041 209195 static INLINE int32_t checkWeaponID(const int32_t ID, const char * const str)
2042 {
2043 209195 return checkBounds(ID, 0, MAXWPNS-1, str);
2044 }
2045
2046 147223 static INLINE int32_t checkWeaponMiscSprite(const int32_t ID, const char * const str)
2047 {
2048 147223 return checkBounds(ID, 0, MAXWPNS-1, str);
2049 }
2050
2051 170815 static INLINE int32_t checkSFXID(const int32_t ID, const char * const str)
2052 {
2053 170815 return checkBounds(ID, 0, WAV_COUNT-1, str);
2054 }
2055
2056 560388282 static INLINE int32_t checkBounds(const int32_t n, const int32_t boundlow, const int32_t boundup, const char * const funcvar)
2057 {
2058
4/4
✓ Branch 0 taken 560388278 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 229 times.
✓ Branch 3 taken 560388049 times.
560388282 if(n < boundlow || n > boundup)
2059 {
2060 233 Z_scripterrlog("Invalid value (%i) passed to '%s'\n", n, funcvar);
2061 233 return _OutOfBounds;
2062 }
2063
2064 560388049 return _NoError;
2065 560388282 }
2066
2067 81862333 static INLINE int32_t checkBoundsPos(const int32_t n, const int32_t boundlow, const int32_t boundup, const char * const funcvar)
2068 {
2069
3/4
✓ Branch 0 taken 81862333 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1584 times.
✓ Branch 3 taken 81860749 times.
81862333 if(n < boundlow || n > boundup)
2070 {
2071 1584 Z_scripterrlog("Invalid position [%i] used to read to '%s'\n", n, funcvar);
2072 1584 return _OutOfBounds;
2073 }
2074
2075 81860749 return _NoError;
2076 81862333 }
2077
2078 19733362 static INLINE int32_t checkBoundsOneIndexed(const int32_t n, const int32_t boundlow, const int32_t boundup, const char * const funcvar)
2079 {
2080
4/4
✓ Branch 0 taken 19719599 times.
✓ Branch 1 taken 13763 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 19719525 times.
19733362 if(n < boundlow || n > boundup)
2081 {
2082 13837 Z_scripterrlog("Invalid value (%i) passed to '%s'\n", n+1, funcvar);
2083 13837 return _OutOfBounds;
2084 }
2085
2086 19719525 return _NoError;
2087 19733362 }
2088
2089 1635186978 static INLINE int32_t checkUserArrayIndex(const int32_t index, const dword size, const bool neg = false)
2090 {
2091
2092
6/6
✓ Branch 0 taken 40454147 times.
✓ Branch 1 taken 1594732831 times.
✓ Branch 2 taken 1634553897 times.
✓ Branch 3 taken 633081 times.
✓ Branch 4 taken 7038 times.
✓ Branch 5 taken 1634546859 times.
1635186978 if(index < (neg ? -int32_t(size) : 0) || index >= int32_t(size))
2093 {
2094 640119 Z_scripterrlog("Invalid index (%ld) to local array of size %ld\n", index, size);
2095 640119 return _OutOfBounds;
2096 }
2097
2098 1634546859 return _NoError;
2099 1635186978 }
2100 };
2101
2102 ///------------------------------------------------//
2103 // Pointer Handling Functions //
2104 ///------------------------------------------------//
2105 //MUST call AND check load functions before trying to use other functions
2106
2107
2108
2109
2110 //Guy Helper
2111 class GuyH : public SH
2112 {
2113
2114 public:
2115 78110851 static int32_t loadNPC(const int32_t eid, const char * const funcvar)
2116 {
2117
2/2
✓ Branch 0 taken 78110704 times.
✓ Branch 1 taken 147 times.
78110851 if ( !eid )
2118 {
2119 //can never be zero?
2120 147 Z_scripterrlog("The npc pointer used for %s is NULL or uninitialised.", funcvar);
2121 147 return _InvalidSpriteUID;
2122 }
2123 78110704 tempenemy = (enemy *) guys.getByUID(eid);
2124
2125
2/2
✓ Branch 0 taken 5901 times.
✓ Branch 1 taken 78104803 times.
78110704 if(tempenemy == NULL)
2126 {
2127 5901 Z_scripterrlog("Invalid NPC with UID %ld passed to %s\nNPCs on screen have UIDs ", eid, funcvar);
2128
2129
2/2
✓ Branch 0 taken 13743 times.
✓ Branch 1 taken 5901 times.
19644 for(word i = 0; i < guys.Count(); i++)
2130 13743 Z_scripterrlog("%ld ", guys.spr(i)->getUID());
2131
2132 5901 Z_scripterrlog("\n");
2133 5901 return _InvalidSpriteUID;
2134 }
2135
2136 78104803 return _NoError;
2137 78110851 }
2138
2139 73297448 static INLINE enemy *getNPC()
2140 {
2141 73297448 return tempenemy;
2142 }
2143
2144 // Currently only used in a context where the enemy is known to be valid,
2145 // so there's no need to print an error
2146 2 static int32_t getNPCIndex(const int32_t eid)
2147 {
2148
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 for(word i = 0; i < guys.Count(); i++)
2149 {
2150
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(guys.spr(i)->getUID() == eid)
2151 2 return i;
2152 }
2153
2154 return -1;
2155 2 }
2156
2157 6431340 static int32_t getNPCDMisc(const byte a)
2158 {
2159
12/33
✓ Branch 0 taken 2128 times.
✓ Branch 1 taken 9365 times.
✓ Branch 2 taken 1308 times.
✓ Branch 3 taken 5650 times.
✓ Branch 4 taken 874 times.
✓ Branch 5 taken 742 times.
✓ Branch 6 taken 107 times.
✓ Branch 7 taken 64 times.
✓ Branch 8 taken 391 times.
✓ Branch 9 taken 383 times.
✓ Branch 10 taken 3262599 times.
✓ Branch 11 taken 3147729 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
6431340 switch(a)
2160 {
2161 2128 case 0: return tempenemy->dmisc1;
2162 9365 case 1: return tempenemy->dmisc2;
2163 1308 case 2: return tempenemy->dmisc3;
2164 5650 case 3: return tempenemy->dmisc4;
2165 874 case 4: return tempenemy->dmisc5;
2166 742 case 5: return tempenemy->dmisc6;
2167 107 case 6: return tempenemy->dmisc7;
2168 64 case 7: return tempenemy->dmisc8;
2169 391 case 8: return tempenemy->dmisc9;
2170 383 case 9: return tempenemy->dmisc10;
2171 3262599 case 10: return tempenemy->dmisc11;
2172 3147729 case 11: return tempenemy->dmisc12;
2173 case 12: return tempenemy->dmisc13;
2174 case 13: return tempenemy->dmisc14;
2175 case 14: return tempenemy->dmisc15;
2176 case 15: return tempenemy->dmisc16;
2177 case 16: return tempenemy->dmisc17;
2178 case 17: return tempenemy->dmisc18;
2179 case 18: return tempenemy->dmisc19;
2180 case 19: return tempenemy->dmisc20;
2181 case 20: return tempenemy->dmisc21;
2182 case 21: return tempenemy->dmisc22;
2183 case 22: return tempenemy->dmisc23;
2184 case 23: return tempenemy->dmisc24;
2185 case 24: return tempenemy->dmisc25;
2186 case 25: return tempenemy->dmisc26;
2187 case 26: return tempenemy->dmisc27;
2188 case 27: return tempenemy->dmisc28;
2189 case 28: return tempenemy->dmisc29;
2190 case 29: return tempenemy->dmisc30;
2191 case 30: return tempenemy->dmisc31;
2192 case 31: return tempenemy->dmisc32;
2193 }
2194
2195 return 0;
2196 6431340 }
2197
2198 4018546 static bool hasHero()
2199 {
2200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4018546 times.
4018546 if(tempenemy->family == eeWALLM)
2201 return ((eWallM *) tempenemy)->hashero;
2202
2203
2/2
✓ Branch 0 taken 216104 times.
✓ Branch 1 taken 3802442 times.
4018546 if(tempenemy->family == eeWALK)
2204 216104 return ((eStalfos *) tempenemy)->hashero;
2205
2206 3802442 return false;
2207 4018546 }
2208
2209 3669986 static int32_t getMFlags()
2210 {
2211 3669986 clear_ornextflag();
2212 3669986 flagpos = 5;
2213 // Must be in the same order as in the Enemy Editor pane
2214 3669986 ornextflag(tempenemy->flags&(lens_only));
2215 3669986 ornextflag(tempenemy->flags2&(guy_flashing));
2216 3669986 ornextflag(tempenemy->flags2&(guy_blinking));
2217 3669986 ornextflag(tempenemy->flags2&(guy_transparent));
2218 3669986 ornextflag(tempenemy->flags&(inv_front));
2219 3669986 ornextflag(tempenemy->flags&(inv_left));
2220 3669986 ornextflag(tempenemy->flags&(inv_right));
2221 3669986 ornextflag(tempenemy->flags&(inv_back));
2222 3669986 ornextflag(tempenemy->flags&(guy_bkshield));
2223 3669986 return (tempenemy->flags&0x1F) | flagval;
2224 }
2225
2226 16354 static INLINE void clearTemp()
2227 {
2228 16354 tempenemy = NULL;
2229 16354 }
2230
2231 private:
2232
2233 static enemy *tempenemy;
2234 };
2235
2236 enemy *GuyH::tempenemy = NULL;
2237
2238 //Item Helper
2239 class ItemH : public SH
2240 {
2241
2242 public:
2243 static int32_t loadItem(const int32_t iid, const char * const funcvar)
2244 {
2245 if ( !iid )
2246 {
2247 //can never be zero?
2248 Z_scripterrlog("The item pointer used for %s is NULL or uninitialised.", funcvar);
2249 return _InvalidSpriteUID;
2250 }
2251
2252 tempitem = (item *) items.getByUID(iid);
2253
2254 if(tempitem == NULL)
2255 {
2256 Z_scripterrlog("Invalid item with UID %ld passed to %s\nItems on screen have UIDs ", iid, funcvar);
2257
2258 for(word i = 0; i < items.Count(); i++)
2259 Z_scripterrlog("%ld ", items.spr(i)->getUID());
2260
2261 Z_scripterrlog("\n");
2262 return _InvalidSpriteUID;
2263 }
2264
2265 return _NoError;
2266 }
2267
2268 2645 static int32_t getItemIndex(const int32_t iid)
2269 {
2270
1/2
✓ Branch 0 taken 3957 times.
✗ Branch 1 not taken.
3957 for(word i = 0; i < items.Count(); i++)
2271 {
2272
2/2
✓ Branch 0 taken 2645 times.
✓ Branch 1 taken 1312 times.
3957 if(items.spr(i)->getUID() == iid)
2273 2645 return i;
2274 1312 }
2275
2276 return -1;
2277 2645 }
2278
2279 static INLINE item* getItem()
2280 {
2281 return tempitem;
2282 }
2283
2284 16354 static INLINE void clearTemp()
2285 {
2286 16354 tempitem = NULL;
2287 16354 }
2288
2289 private:
2290
2291 static item *tempitem;
2292 };
2293
2294 item *ItemH::tempitem = NULL;
2295
2296 //LWeapon Helper
2297 class LwpnH : public SH
2298 {
2299
2300 public:
2301
2302
2303 static defWpnSprite getDefWeaponSprite(weapon *wp)
2304 {
2305 switch(wp->id)
2306 {
2307 case wNone: return ws_0;
2308 case wSword: return ws_0;
2309 case wBeam: return wsBeam;
2310 case wBrang : return wsBrang;
2311 case wBomb: return wsBomb;
2312 case wSBomb: return wsSBomb;
2313 case wLitBomb: return wsBombblast;
2314 case wLitSBomb: return wsBombblast;
2315 case wArrow: return wsArrow;
2316 case wFire: return wsFire;
2317 case wWhistle: return wsUnused45;
2318 case wBait: return wsBait;
2319 case wWand: return wsWandHandle;
2320 case wMagic: return wsMagic;
2321 case wCatching: return wsUnused45;
2322 case wWind: return wsWind;
2323 case wRefMagic: return wsRefMagic;
2324 case wRefFireball: return wsRefFireball;
2325 case wRefRock: return wsRock;
2326 case wHammer: return wsHammer;
2327 case wHookshot: return wsHookshotHead;
2328 case wHSHandle: return wsHookshotHandle;
2329 case wHSChain: return wsHookshotChainH;
2330 case wSSparkle: return wsSilverSparkle;
2331 case wFSparkle: return wsGoldSparkle;
2332 case wSmack: return wsHammerSmack;
2333 case wPhantom: return wsUnused45;
2334 case wCByrna: return wsByrnaCane;
2335 case wRefBeam: return wsRefBeam;
2336 case wStomp: return wsUnused45;
2337 case lwMax: return wsUnused45;
2338 case wScript1:
2339 case wScript2:
2340 case wScript3:
2341 case wScript4:
2342 case wScript5:
2343 case wScript6:
2344 case wScript7:
2345 case wScript8:
2346 case wScript9:
2347 case wScript10: return ws_0;
2348 case wIce: return wsIce; //new
2349 case wFlame: return wsEFire2; //new
2350 //not implemented; t/b/a
2351 case wSound:
2352 case wThrown:
2353 case wPot:
2354 case wLit:
2355 case wBombos:
2356 case wEther:
2357 case wQuake:
2358 case wSword180:
2359 case wSwordLA: return wsUnused45;
2360
2361 case ewFireball: return wsFireball2;
2362 case ewArrow: return wsEArrow;
2363 case ewBrang: return wsBrang;
2364 case ewSword: return wsEBeam;
2365 case ewRock: return wsRock;
2366 case ewMagic: return wsEMagic;
2367 case ewBomb: return wsEBomb;
2368 case ewSBomb: return wsESbomb;
2369 case ewLitBomb: return wsEBombblast;
2370 case ewLitSBomb: return wsESbombblast;
2371 case ewFireTrail: return wsEFiretrail;
2372 case ewFlame: return wsEFire;
2373 case ewWind: return wsEWind;
2374 case ewFlame2: return wsEFire2;
2375 case ewFlame2Trail: return wsEFiretrail2;
2376 case ewIce: return wsIce;
2377 case ewFireball2: return wsFireball2;
2378 default: return wsUnused45;
2379 }
2380 };
2381
2382 15079 static int32_t loadWeapon(const int32_t wid, const char * const funcvar)
2383 {
2384
1/2
✓ Branch 0 taken 15079 times.
✗ Branch 1 not taken.
15079 if ( !wid )
2385 {
2386 //can never be zero?
2387 Z_scripterrlog("The lweapon pointer used for %s is NULL or uninitialised.", funcvar);
2388 return _InvalidSpriteUID;
2389 }
2390 15079 tempweapon = (weapon *) Lwpns.getByUID(wid);
2391
2392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15079 times.
15079 if(tempweapon == NULL)
2393 {
2394 Z_scripterrlog("Invalid lweapon with UID %ld passed to %s\nLWeapons on screen have UIDs ", wid, funcvar);
2395
2396 for(word i = 0; i < Lwpns.Count(); i++)
2397 Z_scripterrlog("%ld ", Lwpns.spr(i)->getUID());
2398
2399 Z_scripterrlog("\n");
2400 return _InvalidSpriteUID;
2401 }
2402
2403 15079 return _NoError;
2404 15079 }
2405
2406 373740 static int32_t getLWeaponIndex(const int32_t lwid)
2407 {
2408
1/2
✓ Branch 0 taken 4154594 times.
✗ Branch 1 not taken.
4154594 for(word i = 0; i < Lwpns.Count(); i++)
2409 {
2410
2/2
✓ Branch 0 taken 373740 times.
✓ Branch 1 taken 3780854 times.
4154594 if(Lwpns.spr(i)->getUID() == lwid)
2411 373740 return i;
2412 3780854 }
2413
2414 return -1;
2415 373740 }
2416
2417 15079 static INLINE weapon *getWeapon()
2418 {
2419 15079 return tempweapon;
2420 }
2421
2422 16354 static INLINE void clearTemp()
2423 {
2424 16354 tempweapon = NULL;
2425 16354 }
2426
2427 private:
2428
2429 static weapon *tempweapon;
2430 };
2431
2432 weapon *LwpnH::tempweapon = NULL;
2433
2434 //EWeapon Helper
2435 class EwpnH : public SH
2436 {
2437
2438 public:
2439
2440 defWpnSprite getDefWeaponSprite(weapon *wp)
2441 {
2442 switch(wp->id)
2443 {
2444 case wNone: return ws_0;
2445 case wSword: return ws_0;
2446 case wBeam: return wsBeam;
2447 case wBrang : return wsBrang;
2448 case wBomb: return wsBomb;
2449 case wSBomb: return wsSBomb;
2450 case wLitBomb: return wsBombblast;
2451 case wLitSBomb: return wsBombblast;
2452 case wArrow: return wsArrow;
2453 case wFire: return wsFire;
2454 case wWhistle: return wsUnused45;
2455 case wBait: return wsBait;
2456 case wWand: return wsWandHandle;
2457 case wMagic: return wsMagic;
2458 case wCatching: return wsUnused45;
2459 case wWind: return wsWind;
2460 case wRefMagic: return wsRefMagic;
2461 case wRefFireball: return wsRefFireball;
2462 case wRefRock: return wsRock;
2463 case wHammer: return wsHammer;
2464 case wHookshot: return wsHookshotHead;
2465 case wHSHandle: return wsHookshotHandle;
2466 case wHSChain: return wsHookshotChainH;
2467 case wSSparkle: return wsSilverSparkle;
2468 case wFSparkle: return wsGoldSparkle;
2469 case wSmack: return wsHammerSmack;
2470 case wPhantom: return wsUnused45;
2471 case wCByrna: return wsByrnaCane;
2472 case wRefBeam: return wsRefBeam;
2473 case wStomp: return wsUnused45;
2474 case lwMax: return wsUnused45;
2475 case wScript1:
2476 case wScript2:
2477 case wScript3:
2478 case wScript4:
2479 case wScript5:
2480 case wScript6:
2481 case wScript7:
2482 case wScript8:
2483 case wScript9:
2484 case wScript10: return ws_0;
2485 case wIce: return wsIce; //new
2486 case wFlame: return wsEFire2; //new
2487 //not implemented; t/b/a
2488 case wSound:
2489 case wThrown:
2490 case wPot:
2491 case wLit:
2492 case wBombos:
2493 case wEther:
2494 case wQuake:
2495 case wSword180:
2496 case wSwordLA: return wsUnused45;
2497
2498 case ewFireball: return wsFireball2;
2499 case ewArrow: return wsEArrow;
2500 case ewBrang: return wsBrang;
2501 case ewSword: return wsEBeam;
2502 case ewRock: return wsRock;
2503 case ewMagic: return wsEMagic;
2504 case ewBomb: return wsEBomb;
2505 case ewSBomb: return wsESbomb;
2506 case ewLitBomb: return wsEBombblast;
2507 case ewLitSBomb: return wsESbombblast;
2508 case ewFireTrail: return wsEFiretrail;
2509 case ewFlame: return wsEFire;
2510 case ewWind: return wsEWind;
2511 case ewFlame2: return wsEFire2;
2512 case ewFlame2Trail: return wsEFiretrail2;
2513 case ewIce: return wsIce;
2514 case ewFireball2: return wsFireball2;
2515 default: return wsUnused45;
2516 }
2517 };
2518
2519 132144 static int32_t loadWeapon(const int32_t wid, const char * const funcvar)
2520 {
2521
1/2
✓ Branch 0 taken 132144 times.
✗ Branch 1 not taken.
132144 if ( !wid )
2522 {
2523 //can never be zero?
2524 Z_scripterrlog("The eweapon pointer used for %s is NULL or uninitialised.", funcvar);
2525 return _InvalidSpriteUID;
2526 }
2527 132144 tempweapon = (weapon *) Ewpns.getByUID(wid);
2528
2529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132144 times.
132144 if(tempweapon == NULL)
2530 {
2531 Z_scripterrlog("Invalid eweapon with UID %ld passed to %s\nEWeapons on screen have UIDs ", wid, funcvar);
2532
2533 for(word i = 0; i < Ewpns.Count(); i++)
2534 Z_scripterrlog("%ld ", Ewpns.spr(i)->getUID());
2535
2536 Z_scripterrlog("\n");
2537 return _InvalidSpriteUID;
2538 }
2539
2540 132144 return _NoError;
2541 132144 }
2542
2543 119542 static int32_t getEWeaponIndex(const int32_t ewid)
2544 {
2545
1/2
✓ Branch 0 taken 490280 times.
✗ Branch 1 not taken.
490280 for(word i = 0; i < Ewpns.Count(); i++)
2546 {
2547
2/2
✓ Branch 0 taken 119542 times.
✓ Branch 1 taken 370738 times.
490280 if(Ewpns.spr(i)->getUID() == ewid)
2548 119542 return i;
2549 370738 }
2550
2551 return -1;
2552 119542 }
2553
2554 132144 static INLINE weapon *getWeapon()
2555 {
2556 132144 return tempweapon;
2557 }
2558
2559 16354 static INLINE void clearTemp()
2560 {
2561 16354 tempweapon = NULL;
2562 16354 }
2563
2564 private:
2565
2566 static weapon *tempweapon;
2567 };
2568
2569 weapon *EwpnH::tempweapon = NULL;
2570
2571 16354 void clearScriptHelperData()
2572 {
2573 16354 GuyH::clearTemp();
2574 16354 ItemH::clearTemp();
2575 16354 LwpnH::clearTemp();
2576 16354 EwpnH::clearTemp();
2577 16354 }
2578
2579 ///---------------------------------------------//
2580 // Array Helper Functions //
2581 ///---------------------------------------------//
2582
2583 class ArrayManager
2584 {
2585 public:
2586 ArrayManager(int32_t ptr, bool neg);
2587 ArrayManager(int32_t ptr);
2588
2589 int32_t get(int32_t indx) const;
2590 void set(int32_t indx, int32_t val);
2591 int32_t size() const;
2592
2593 bool resize(size_t newsize);
2594
2595 1986664 bool invalid() const {return _invalid;}
2596 bool internal() const {return !_invalid && !aptr;}
2597
2598 std::string asString(std::function<char const*(int32_t)> formatter, const size_t& limit) const;
2599
2600 bool negAccess;
2601 private:
2602 int32_t ptr;
2603 ZScriptArray* aptr;
2604 bool _invalid;
2605 };
2606
2607 //Array Helper
2608 class ArrayH : public SH
2609 {
2610 public:
2611 294114413 static size_t getSize(const int32_t ptr)
2612 {
2613 294114413 ArrayManager am(ptr);
2614 294114413 return am.size();
2615 }
2616
2617 //Can't you get the std::string and then check its length?
2618 static int32_t strlen(const int32_t ptr)
2619 {
2620 ArrayManager am(ptr);
2621 if (am.invalid())
2622 return -1;
2623
2624 word count;
2625 size_t sz = am.size();
2626 for(count = 0; BC::checkUserArrayIndex(count, sz) == _NoError
2627 && am.get(count) != '\0'; count++);
2628
2629 return count;
2630 }
2631
2632 //Returns values of a zscript array as an std::string.
2633 1712134 static void getString(const int32_t ptr, string &str, dword num_chars = ZSCRIPT_MAX_STRING_CHARS, dword offset = 0)
2634 {
2635 1712134 ArrayManager am(ptr);
2636
2637
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1712129 times.
1712134 if(am.invalid())
2638 {
2639 5 str.clear();
2640 5 return;
2641 }
2642
2643 1712129 str.clear();
2644 1712129 size_t sz = am.size();
2645
5/6
✓ Branch 0 taken 19859438 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1712129 times.
✓ Branch 3 taken 18147309 times.
✓ Branch 4 taken 1712129 times.
✓ Branch 5 taken 18147309 times.
19859438 for(word i = offset; BC::checkUserArrayIndex(i, sz) == _NoError && am.get(i) != '\0' && num_chars != 0; i++)
2646 {
2647 18147309 int32_t c = am.get(i) / 10000;
2648
1/2
✓ Branch 0 taken 18147309 times.
✗ Branch 1 not taken.
18147309 if(char(c) != c)
2649 {
2650 Z_scripterrlog("Illegal char value (%d) at position [%d] in string pointer %d\n", c, i, ptr);
2651 Z_scripterrlog("Value of invalid char will overflow.\n");
2652 }
2653 18147309 str += char(c);
2654 18147309 --num_chars;
2655 18147309 }
2656 1712134 }
2657
2658 //Used for issues where reading the ZScript array floods the console with errors 'Accessing array index [12] size of 12.
2659 //Happens with Quad3D and some other functions, and I have no clue why. -Z ( 28th April, 2019 )
2660 //Like getString but for an array of longs instead of chars. *(arrayPtr is not checked for validity)
2661 static void getValues2(const int32_t ptr, int32_t* arrayPtr, dword num_values, dword offset = 0) //a hack -Z
2662 {
2663 ArrayManager am(ptr);
2664
2665 if(am.invalid())
2666 return;
2667
2668 size_t sz = am.size();
2669 for(word i = offset; BC::checkUserArrayIndex(i, sz+1) == _NoError && num_values != 0; i++)
2670 {
2671 arrayPtr[i] = (am.get(i) / 10000);
2672 num_values--;
2673 }
2674 }
2675
2676 //Like getString but for an array of longs instead of chars. *(arrayPtr is not checked for validity)
2677 static void getValues(const int32_t ptr, int32_t* arrayPtr, dword num_values, dword offset = 0)
2678 {
2679 ArrayManager am(ptr);
2680
2681 if (am.invalid())
2682 return;
2683 size_t sz = am.size();
2684 for(word i = offset; BC::checkUserArrayIndex(i, sz) == _NoError && num_values != 0; i++)
2685 {
2686 arrayPtr[i] = (am.get(i) / 10000);
2687 num_values--;
2688 }
2689 }
2690
2691 static void copyValues(const int32_t ptr, const int32_t ptr2, size_t num_values)
2692 {
2693 ArrayManager am1(ptr), am2(ptr2);
2694 if(am1.invalid() || am2.invalid())
2695 return;
2696 size_t sz = std::min(am1.size(),am2.size());
2697 for(word i = 0; (BC::checkUserArrayIndex(i, sz) == _NoError) && num_values != 0; i++)
2698 {
2699 am1.set(i,am2.get(i));
2700 num_values--;
2701 }
2702 }
2703 //Get element from array
2704 1046842629 static INLINE int32_t getElement(const int32_t ptr, int32_t offset,
2705 const bool neg = false)
2706 {
2707 1046842629 ArrayManager am(ptr,neg);
2708 1046842629 return am.get(offset);
2709 }
2710
2711 //Set element in array
2712 518658645 static INLINE void setElement(const int32_t ptr, int32_t offset,
2713 const int32_t value, const bool neg = false)
2714 {
2715 518658645 ArrayManager am(ptr,neg);
2716 518658645 am.set(offset,value);
2717 518658645 }
2718
2719 //Puts values of a zscript array into a client <type> array. returns 0 on success. Overloaded
2720 template <typename T>
2721 static int32_t getArray(const int32_t ptr, T *refArray)
2722 {
2723 return getArray(ptr, getSize(ptr), 0, 0, 0, refArray);
2724 }
2725
2726 template <typename T>
2727 static int32_t getArray(const int32_t ptr, const word size, T *refArray)
2728 {
2729 return getArray(ptr, size, 0, 0, 0, refArray);
2730 }
2731
2732 template <typename T>
2733 static int32_t getArray(const int32_t ptr, const word size, word userOffset, const word userStride, const word refArrayOffset, T *refArray)
2734 {
2735 ArrayManager am(ptr);
2736
2737 if (am.invalid())
2738 return _InvalidPointer;
2739
2740 word j = 0, k = userStride;
2741
2742 size_t sz = am.size();
2743 for(word i = 0; j < size; i++)
2744 {
2745 if(i >= sz)
2746 return _Overflow;
2747
2748 if(userOffset-- > 0)
2749 continue;
2750
2751 if(k > 0)
2752 k--;
2753 else if(BC::checkUserArrayIndex(i, sz) == _NoError)
2754 {
2755 refArray[j + refArrayOffset] = T(am.get(i));
2756 k = userStride;
2757 j++;
2758 }
2759 }
2760
2761 return _NoError;
2762 }
2763
2764 265856 static int32_t setArray(const int32_t ptr, string const& s2)
2765 {
2766 265856 ArrayManager am(ptr);
2767
2768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 265856 times.
265856 if (am.invalid())
2769 return _InvalidPointer;
2770
2771 word i;
2772
2773 265856 size_t sz = am.size();
2774
2/2
✓ Branch 0 taken 5642234 times.
✓ Branch 1 taken 265808 times.
5908042 for(i = 0; i < s2.size(); i++)
2775 {
2776
2/2
✓ Branch 0 taken 5642186 times.
✓ Branch 1 taken 48 times.
5642234 if(i >= sz)
2777 {
2778 48 am.set(sz-1,'\0');
2779 48 return _Overflow;
2780 }
2781
2782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5642186 times.
5642186 if(BC::checkUserArrayIndex(i, sz) == _NoError)
2783 5642186 am.set(i,s2[i] * 10000);
2784 5642186 }
2785
2786
1/2
✓ Branch 0 taken 265808 times.
✗ Branch 1 not taken.
265808 if(BC::checkUserArrayIndex(i, sz) == _NoError)
2787 265808 am.set(i,'\0');
2788
2789 265808 return _NoError;
2790 265856 }
2791
2792 //Puts values of a client <type> array into a zscript array. returns 0 on success. Overloaded
2793 template <typename T>
2794 334 static int32_t setArray(const int32_t ptr, const word size, T *refArray, bool x10k = true)
2795 {
2796 334 return setArray(ptr, size, 0, 0, 0, refArray, x10k);
2797 }
2798
2799 template <typename T>
2800 334 static int32_t setArray(const int32_t ptr, const word size, word userOffset, const word userStride, const word refArrayOffset, T *refArray, bool x10k = true)
2801 {
2802 334 ArrayManager am(ptr);
2803
2804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 if (am.invalid())
2805 return _InvalidPointer;
2806
2807 334 word j = 0, k = userStride;
2808 334 size_t sz = am.size();
2809
2/2
✓ Branch 0 taken 1760 times.
✓ Branch 1 taken 334 times.
2094 for(word i = 0; j < size; i++)
2810 {
2811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1760 times.
1760 if(i >= sz)
2812 return _Overflow; //Resize?
2813
2814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1760 times.
1760 if (userOffset > 0)
2815 {
2816 --userOffset;
2817 continue;
2818 }
2819
2820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1760 times.
1760 if(k > 0)
2821 k--;
2822
1/2
✓ Branch 0 taken 1760 times.
✗ Branch 1 not taken.
1760 else if(BC::checkUserArrayIndex(i, sz) == _NoError)
2823 {
2824 1760 am.set(i,int32_t(refArray[j + refArrayOffset]) * (x10k ? 10000 : 1));
2825 1760 k = userStride;
2826 1760 j++;
2827 1760 }
2828 1760 }
2829
2830 334 return _NoError;
2831 334 }
2832 };
2833
2834 1861602351 ArrayManager::ArrayManager(int32_t ptr, bool neg) : ptr(ptr), negAccess(neg)
2835 {
2836 1861602351 _invalid = false;
2837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1861602351 times.
1861602351 if(ptr >= INTARR_OFFS)
2838 {
2839 aptr = nullptr;
2840 if(sz_int_arr(ptr) < 0)
2841 _invalid = true;
2842 }
2843
2/2
✓ Branch 0 taken 1861601708 times.
✓ Branch 1 taken 643 times.
1861602351 else if(ptr == 0)
2844 {
2845 643 aptr = &INVALIDARRAY;
2846 643 _invalid = true;
2847 643 }
2848
1/2
✓ Branch 0 taken 1861601708 times.
✗ Branch 1 not taken.
1861601708 else if(ptr < 0) //An object array?
2849 {
2850 int32_t objptr = -ptr;
2851 auto it = objectRAM.find(objptr);
2852 if(it == objectRAM.end())
2853 {
2854 aptr = &INVALIDARRAY;
2855 _invalid = true;
2856 }
2857 else aptr = &(it->second);
2858 }
2859
2/2
✓ Branch 0 taken 1601042483 times.
✓ Branch 1 taken 260559225 times.
1861601708 else if(ptr >= NUM_ZSCRIPT_ARRAYS) //Then it's a global
2860 {
2861 1601042483 dword gptr = ptr - NUM_ZSCRIPT_ARRAYS;
2862
2863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1601042483 times.
1601042483 if(gptr > game->globalRAM.size())
2864 {
2865 aptr = &INVALIDARRAY;
2866 _invalid = true;
2867 }
2868 1601042483 else aptr = &(game->globalRAM[gptr]);
2869 1601042483 }
2870 else
2871 {
2872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 260559225 times.
260559225 if(localRAM[ptr].Size() == 0)
2873 {
2874 aptr = &INVALIDARRAY;
2875 _invalid = true;
2876 }
2877 260559225 else aptr = &(localRAM[ptr]);
2878 }
2879
2/2
✓ Branch 0 taken 1861601708 times.
✓ Branch 1 taken 643 times.
1861602351 if(_invalid)
2880 {
2881 643 Z_scripterrlog("Invalid pointer (%i) passed to array "
2882 643 "(don't change the values of your array pointers)\n", ptr);
2883 643 }
2884 1861602351 }
2885 296101077 ArrayManager::ArrayManager(int32_t ptr) : ArrayManager(ptr,can_neg_array){}
2886
2887 1084849504 int32_t ArrayManager::get(int32_t indx) const
2888 {
2889
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 1084849339 times.
1084849504 if(_invalid) return -10000;
2890 1084849339 int32_t sz = size();
2891
1/2
✓ Branch 0 taken 1084849339 times.
✗ Branch 1 not taken.
1084849339 if(aptr)
2892 {
2893
2/2
✓ Branch 0 taken 1084215925 times.
✓ Branch 1 taken 633414 times.
1084849339 if(BC::checkUserArrayIndex(indx, sz, negAccess) == SH::_NoError)
2894 {
2895
1/2
✓ Branch 0 taken 1084215925 times.
✗ Branch 1 not taken.
1084215925 if(indx < 0)
2896 indx += sz; //[-1] becomes [size-1] -Em
2897 1084215925 return (*aptr)[indx];
2898 }
2899 633414 }
2900 else //internal special array
2901 {
2902 if(sz >= 0 && BC::checkUserArrayIndex(indx, sz, negAccess) == SH::_NoError)
2903 {
2904 if(indx < 0)
2905 indx += sz; //[-1] becomes [size-1] -Em
2906 return get_int_arr(ptr, indx);
2907 }
2908 }
2909 633414 return -10000;
2910 1084849504 }
2911 524568447 void ArrayManager::set(int32_t indx, int32_t val)
2912 {
2913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 524568447 times.
524568447 if(_invalid) return;
2914 524568447 int32_t sz = size();
2915
1/2
✓ Branch 0 taken 524568447 times.
✗ Branch 1 not taken.
524568447 if(aptr)
2916 {
2917
2/2
✓ Branch 0 taken 524561742 times.
✓ Branch 1 taken 6705 times.
524568447 if(BC::checkUserArrayIndex(indx, sz, negAccess) == SH::_NoError)
2918 {
2919
1/2
✓ Branch 0 taken 524561742 times.
✗ Branch 1 not taken.
524561742 if(indx < 0)
2920 indx += sz; //[-1] becomes [size-1] -Em
2921 524561742 (*aptr)[indx] = val;
2922 524561742 }
2923 524568447 }
2924 else //internal special array
2925 {
2926 if(sz >= 0 && BC::checkUserArrayIndex(indx, sz, negAccess) == SH::_NoError)
2927 {
2928 if(indx < 0)
2929 indx += sz; //[-1] becomes [size-1] -Em
2930 set_int_arr(ptr, indx, val);
2931 }
2932 }
2933 524568447 }
2934 1905510534 int32_t ArrayManager::size() const
2935 {
2936
2/2
✓ Branch 0 taken 473 times.
✓ Branch 1 taken 1905510061 times.
1905510534 if(_invalid) return -1;
2937
1/2
✓ Branch 0 taken 1905510061 times.
✗ Branch 1 not taken.
1905510061 if(aptr)
2938 1905510061 return aptr->Size();
2939 else // Internal special
2940 {
2941 int32_t sz = sz_int_arr(ptr);
2942 if(sz < 0)
2943 return -1;
2944 return sz;
2945 }
2946 1905510534 }
2947
2948 bool ArrayManager::resize(size_t newsize)
2949 {
2950 if(_invalid) return false;
2951 if(!aptr)
2952 {
2953 Z_scripterrlog("Special internal array '%d' not valid for operation 'Resize'\n", ptr);
2954 return false;
2955 }
2956 aptr->Resize(newsize);
2957 return true;
2958 }
2959
2960 std::string ArrayManager::asString(std::function<char const*(int32_t)> formatter, const size_t& limit) const
2961 {
2962 if(_invalid) return "{ INVALID ARRAY }";
2963 std::ostringstream oss;
2964 oss << "{ ";
2965 size_t s = size();
2966 bool overflow = limit < s;
2967 if(overflow)
2968 s = limit;
2969
2970 for(auto q = 0; q < s; ++q)
2971 {
2972 oss << formatter(get(q));
2973 if (q + 1 < s)
2974 oss << ", ";
2975 }
2976 if (overflow)
2977 oss << ", ...";
2978 oss << " }";
2979 return oss.str();
2980 }
2981
2982 // Called to deallocate arrays when a script stops running
2983 24497 void deallocateArray(const int32_t ptrval)
2984 {
2985
1/2
✓ Branch 0 taken 24497 times.
✗ Branch 1 not taken.
24497 if(ptrval == 0) return;
2986
2/4
✓ Branch 0 taken 24497 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24497 times.
24497 if(ptrval==0 || ptrval >= NUM_ZSCRIPT_ARRAYS)
2987 Z_scripterrlog("Script tried to deallocate memory at invalid address %ld\n", ptrval);
2988
1/2
✓ Branch 0 taken 24497 times.
✗ Branch 1 not taken.
24497 else if(ptrval<0)
2989 Z_scripterrlog("Script tried to deallocate memory at object-based address %ld\n", ptrval);
2990 else
2991 {
2992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24497 times.
24497 if(arrayOwner[ptrval].specOwned) return; //ignore this deallocation
2993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24497 times.
24497 if(arrayOwner[ptrval].specCleared) return;
2994 24497 arrayOwner[ptrval].clear();
2995
2996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24497 times.
24497 if(localRAM[ptrval].Size() == 0)
2997 Z_scripterrlog("Script tried to deallocate memory that was not allocated at address %ld\n", ptrval);
2998 else
2999 {
3000 24497 word size = localRAM[ptrval].Size();
3001 24497 localRAM[ptrval].Clear();
3002
3003 // If this happens once per frame, it can drown out every other message. -L
3004 //Z_eventlog("Deallocated local array with address %ld, size %d\n", ptrval, size);
3005 24497 size = size;
3006 }
3007 }
3008 24497 }
3009
3010 3597090 void FFScript::deallocateAllArrays(ScriptType scriptType, const int32_t UID, bool requireAlways)
3011 {
3012
2/2
✓ Branch 0 taken 895675410 times.
✓ Branch 1 taken 3597090 times.
899272500 for(int32_t q = MIN_USER_BITMAPS; q < MAX_USER_BITMAPS; ++q)
3013 {
3014 895675410 scb.script_created_bitmaps[q].own_clear(scriptType, UID);
3015 895675410 }
3016
2/2
✓ Branch 0 taken 920855040 times.
✓ Branch 1 taken 3597090 times.
924452130 for(int32_t q = 0; q < MAX_USER_RNGS; ++q)
3017 {
3018 920855040 script_rngs[q].own_clear(scriptType, UID);
3019 920855040 }
3020
2/2
✓ Branch 0 taken 920855040 times.
✓ Branch 1 taken 3597090 times.
924452130 for (int32_t q = 0; q < MAX_USER_PALDATAS; ++q)
3021 {
3022 920855040 script_paldatas[q].own_clear(scriptType, UID);
3023 920855040 }
3024
2/2
✓ Branch 0 taken 920855040 times.
✓ Branch 1 taken 3597090 times.
924452130 for(int32_t q = 0; q < MAX_USER_FILES; ++q)
3025 {
3026 920855040 script_files[q].own_clear(scriptType, UID);
3027 920855040 }
3028
2/2
✓ Branch 0 taken 920855040 times.
✓ Branch 1 taken 3597090 times.
924452130 for(int32_t q = 0; q < MAX_USER_DIRS; ++q)
3029 {
3030 920855040 script_dirs[q].own_clear(scriptType, UID);
3031 920855040 }
3032
2/2
✓ Branch 0 taken 920855040 times.
✓ Branch 1 taken 3597090 times.
924452130 for(int32_t q = 0; q < MAX_USER_STACKS; ++q)
3033 {
3034 920855040 script_stacks[q].own_clear(scriptType, UID);
3035 920855040 }
3036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3597090 times.
3597090 for(int32_t q = 0; q < max_valid_object; ++q)
3037 {
3038 script_objects[q].own_clear(scriptType, UID);
3039 }
3040
4/4
✓ Branch 0 taken 1511858 times.
✓ Branch 1 taken 2085232 times.
✓ Branch 2 taken 237468 times.
✓ Branch 3 taken 1274390 times.
3597090 if(requireAlways && !get_qr(qr_ALWAYS_DEALLOCATE_ARRAYS))
3041 {
3042 //Keep 2.50.2 behavior if QR unchecked.
3043
2/2
✓ Branch 0 taken 1255741 times.
✓ Branch 1 taken 18649 times.
1274390 switch(scriptType)
3044 {
3045 case ScriptType::FFC:
3046 case ScriptType::Item:
3047 case ScriptType::Global:
3048 18649 return;
3049 }
3050 1255741 }
3051 //Z_eventlog("Attempting array deallocation from %s UID %d\n", script_types[scriptType], UID);
3052
2/2
✓ Branch 0 taken 3578441 times.
✓ Branch 1 taken 14653715895 times.
14657294336 for(int32_t i = 1; i < NUM_ZSCRIPT_ARRAYS; i++)
3053 {
3054
4/4
✓ Branch 0 taken 169221 times.
✓ Branch 1 taken 14653546674 times.
✓ Branch 2 taken 147697 times.
✓ Branch 3 taken 21524 times.
14653715895 if(arrayOwner[i].scriptType == scriptType && arrayOwner[i].ownerUID==UID)
3055 {
3056 21524 arrayOwner[i].specOwned = false;
3057 21524 deallocateArray(i);
3058 //Z_eventlog("Deallocated array %d from %s UID %d\n", i, script_types[scriptType], UID);
3059 21524 }
3060 14653715895 }
3061 3597090 }
3062
3063 392 void FFScript::deallocateAllArrays()
3064 {
3065
2/2
✓ Branch 0 taken 97608 times.
✓ Branch 1 taken 392 times.
98000 for(int32_t q = MIN_USER_BITMAPS; q < MAX_USER_BITMAPS; ++q)
3066 {
3067 97608 scb.script_created_bitmaps[q].own_clear_any();
3068 97608 }
3069
2/2
✓ Branch 0 taken 100352 times.
✓ Branch 1 taken 392 times.
100744 for(int32_t q = 0; q < MAX_USER_RNGS; ++q)
3070 {
3071 100352 script_rngs[q].own_clear_any();
3072 100352 }
3073
2/2
✓ Branch 0 taken 100352 times.
✓ Branch 1 taken 392 times.
100744 for (int32_t q = 0; q < MAX_USER_PALDATAS; ++q)
3074 {
3075 100352 script_paldatas[q].own_clear_any();
3076 100352 }
3077
2/2
✓ Branch 0 taken 100352 times.
✓ Branch 1 taken 392 times.
100744 for(int32_t q = 0; q < MAX_USER_FILES; ++q)
3078 {
3079 100352 script_files[q].own_clear_any();
3080 100352 }
3081
2/2
✓ Branch 0 taken 100352 times.
✓ Branch 1 taken 392 times.
100744 for(int32_t q = 0; q < MAX_USER_DIRS; ++q)
3082 {
3083 100352 script_dirs[q].own_clear_any();
3084 100352 }
3085
2/2
✓ Branch 0 taken 100352 times.
✓ Branch 1 taken 392 times.
100744 for(int32_t q = 0; q < MAX_USER_STACKS; ++q)
3086 {
3087 100352 script_stacks[q].own_clear_any();
3088 100352 }
3089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 392 times.
392 for(int32_t q = 0; q < max_valid_object; ++q)
3090 {
3091 script_objects[q].own_clear_any();
3092 }
3093 //No QR check here- always deallocate on quest exit.
3094
2/2
✓ Branch 0 taken 1605240 times.
✓ Branch 1 taken 392 times.
1605632 for(int32_t i = 1; i < NUM_ZSCRIPT_ARRAYS; i++)
3095 {
3096
2/2
✓ Branch 0 taken 1602267 times.
✓ Branch 1 taken 2973 times.
1605240 if(localRAM[i].Size() > 0)
3097 {
3098 2973 arrayOwner[i].specOwned = false;
3099 //Z_eventlog("Deallocated array %d from %s UID %d\n", i, script_types[arrayOwner[i].scriptType], arrayOwner[i].ownerUID);
3100 2973 deallocateArray(i);
3101 2973 }
3102 1605240 }
3103 392 }
3104
3105 409929 item *checkItem(int32_t iid)
3106 {
3107 409929 item *s = (item *)items.getByUID(iid);
3108
3109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 409929 times.
409929 if(s == NULL)
3110 {
3111 Z_eventlog("Script attempted to reference a nonexistent item!\n");
3112 Z_eventlog("You were trying to reference an item with UID = %ld; Items on screen are UIDs ", iid);
3113
3114 for(int32_t i=0; i<items.Count(); i++)
3115 {
3116 Z_eventlog("%ld ", items.spr(i)->getUID());
3117 }
3118
3119 Z_eventlog("\n");
3120 return NULL;
3121 }
3122
3123 409929 return s;
3124 409929 }
3125
3126 10101294 weapon *checkLWpn(int32_t eid, const char *what)
3127 {
3128 10101294 weapon *s = (weapon *)Lwpns.getByUID(eid);
3129
2/2
✓ Branch 0 taken 9984849 times.
✓ Branch 1 taken 116445 times.
10101294 if(s == NULL) //check lifted weapon
3130 {
3131 116445 weapon* lw = Hero.lift_wpn;
3132
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 116445 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
116445 if(lw && lw->getUID() == eid)
3133 s = lw;
3134 116445 }
3135
2/2
✓ Branch 0 taken 9984849 times.
✓ Branch 1 taken 116445 times.
10101294 if(s == NULL)
3136 {
3137
3138 116445 Z_eventlog("Script attempted to reference a nonexistent LWeapon!\n");
3139 116445 Z_eventlog("You were trying to reference the %s of an LWeapon with UID = %ld; LWeapons on screen are UIDs ", what, eid);
3140
3141
2/2
✓ Branch 0 taken 71278 times.
✓ Branch 1 taken 116445 times.
187723 for(int32_t i=0; i<Lwpns.Count(); i++)
3142 {
3143 71278 Z_eventlog("%ld ", Lwpns.spr(i)->getUID());
3144 71278 }
3145
3146 116445 Z_eventlog("\n");
3147 116445 return NULL;
3148 }
3149
3150 9984849 return s;
3151 10101294 }
3152
3153 23422487 weapon *checkEWpn(int32_t eid, const char *what)
3154 {
3155 23422487 weapon *s = (weapon *)Ewpns.getByUID(eid);
3156
3157
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 23422483 times.
23422487 if(s == NULL)
3158 {
3159
3160 4 Z_eventlog("Script attempted to reference a nonexistent EWeapon!\n");
3161 4 Z_eventlog("You were trying to reference the %s of an EWeapon with UID = %ld; EWeapons on screen are UIDs ", what, eid);
3162
3163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 for(int32_t i=0; i<Ewpns.Count(); i++)
3164 {
3165 Z_eventlog("%ld ", Ewpns.spr(i)->getUID());
3166 }
3167
3168 4 Z_eventlog("\n");
3169 4 return NULL;
3170 }
3171
3172 23422483 return s;
3173 23422487 }
3174
3175 286 user_file *checkFile(int32_t ref, const char *what, bool req_file = false, bool skipError = false)
3176 {
3177
3/4
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 284 times.
286 if(ref > 0 && ref <= MAX_USER_FILES)
3178 {
3179 284 user_file* f = &script_files[ref-1];
3180
1/2
✓ Branch 0 taken 284 times.
✗ Branch 1 not taken.
284 if(f->reserved)
3181 {
3182
3/4
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 280 times.
284 if(req_file && !f->file)
3183 {
3184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280 times.
280 if(skipError) return NULL;
3185 280 Z_scripterrlog("Script attempted to reference an invalid file!\n");
3186 280 Z_scripterrlog("File with UID = %ld does not have an open file connection!\n",ref);
3187 280 Z_scripterrlog("Use '->Open()' or '->Create()' to hook to a system file.\n");
3188 280 return NULL;
3189 }
3190 4 return f;
3191 }
3192 }
3193
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(skipError) return NULL;
3194 Z_scripterrlog("Script attempted to reference a nonexistent File!\n");
3195 if(what)
3196 Z_scripterrlog("You were trying to reference the '%s' of a File with UID = %ld\n", what, ref);
3197 else
3198 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3199 return NULL;
3200 286 }
3201
3202 user_object *checkObject(int32_t ref, bool skipError = false)
3203 {
3204 if(ref > 0 && ref <= MAX_USER_FILES)
3205 {
3206 user_object* obj = &script_objects[ref-1];
3207 if(obj->reserved)
3208 {
3209 return obj;
3210 }
3211 }
3212 if(skipError) return NULL;
3213 Z_scripterrlog("Script attempted to reference a nonexistent object!\n");
3214 Z_scripterrlog("You were trying to reference an object with UID = %ld\n", ref);
3215 return NULL;
3216 }
3217
3218 132 user_genscript *checkGenericScr(int32_t ref, const char *what)
3219 {
3220
2/4
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 if(ref < 1 || ref >= NUMSCRIPTSGENERIC)
3221 {
3222 Z_scripterrlog("Invalid gendata pointer access (%ld) for '->%s'\n", ref, what);
3223 return NULL;
3224 }
3225 132 return &user_scripts[ref];
3226 132 }
3227 extern portal mirror_portal;
3228 portal *checkPortal(int32_t ref, const char *what, bool skiperr = false)
3229 {
3230 if(ref == -1)
3231 return &mirror_portal;
3232 portal* p = (portal*)portals.getByUID(ref);
3233 if(!p)
3234 {
3235 if(!skiperr)
3236 Z_scripterrlog("Invalid portal pointer access (%ld) for '->%s'\n", ref, what);
3237 return nullptr;
3238 }
3239 return p;
3240 }
3241
3242 savedportal *checkSavedPortal(int32_t ref, const char* what, bool skiperr = false)
3243 {
3244 savedportal* sp = game->getSavedPortal(ref);
3245 if(!sp)
3246 {
3247 if(!skiperr)
3248 Z_scripterrlog("Invalid savedportal pointer access (%ld) for '->%s'\n", ref, what);
3249 return nullptr;
3250 }
3251 return sp;
3252 }
3253 int32_t getPortalFromSaved(savedportal* p)
3254 {
3255 if(p == &(game->saved_mirror_portal))
3256 return -1;
3257 portal* prtl = nullptr;
3258 portals.forEach([&](sprite& spr)
3259 {
3260 portal* tmp = (portal*)&spr;
3261 if(p->getUID() == tmp->saved_data)
3262 {
3263 prtl = tmp;
3264 return true;
3265 }
3266 return false;
3267 });
3268 return prtl ? prtl->getUID() : 0;
3269 }
3270
3271 user_dir *checkDir(int32_t ref, const char *what, bool skipError = false)
3272 {
3273 if(ref > 0 && ref <= MAX_USER_DIRS)
3274 {
3275 user_dir* dr = &script_dirs[ref-1];
3276 if(dr->reserved)
3277 {
3278 return dr;
3279 }
3280 }
3281 if(skipError) return NULL;
3282 Z_scripterrlog("Script attempted to reference a nonexistent Directory!\n");
3283 if(what)
3284 Z_scripterrlog("You were trying to reference the '%s' of a Directory with UID = %ld\n", what, ref);
3285 else
3286 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3287 return NULL;
3288 }
3289
3290 user_stack *checkStack(int32_t ref, const char *what, bool skipError = false)
3291 {
3292 if(ref > 0 && ref <= USERSTACK_MAX_SIZE)
3293 {
3294 user_stack* st = &script_stacks[ref-1];
3295 if(st->reserved)
3296 {
3297 return st;
3298 }
3299 }
3300 if(skipError) return NULL;
3301 Z_scripterrlog("Script attempted to reference a nonexistent Stack!\n");
3302 if(what)
3303 Z_scripterrlog("You were trying to reference the '%s' of a Stack with UID = %ld\n", what, ref);
3304 else
3305 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3306 return NULL;
3307 }
3308
3309 303330 user_rng *checkRNG(int32_t ref, const char *what, bool skipError = false)
3310 {
3311
3/4
✓ Branch 0 taken 1523 times.
✓ Branch 1 taken 301807 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1523 times.
303330 if(ref > 0 && ref <= MAX_USER_RNGS)
3312 {
3313 1523 user_rng* rng = &script_rngs[ref-1];
3314
1/2
✓ Branch 0 taken 1523 times.
✗ Branch 1 not taken.
1523 if(rng->reserved)
3315 {
3316 1523 return rng;
3317 }
3318 }
3319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 301807 times.
301807 else if(!ref) //A null RNG pointer is special-case, access engine rng.
3320 {
3321 301807 return &nulrng;
3322 }
3323 if(skipError) return NULL;
3324 Z_scripterrlog("Script attempted to reference a nonexistent RNG!\n");
3325 if(what)
3326 Z_scripterrlog("You were trying to reference the '%s' of a RNG with UID = %ld\n", what, ref);
3327 else
3328 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3329 return NULL;
3330 303330 }
3331
3332 user_paldata* checkPalData(int32_t ref, const char* what, bool skipError = false)
3333 {
3334 if (ref > 0 && ref <= MAX_USER_PALDATAS)
3335 {
3336 user_paldata* pd = &script_paldatas[ref - 1];
3337 if (pd->reserved)
3338 {
3339 return pd;
3340 }
3341 }
3342 if (skipError) return NULL;
3343 Z_scripterrlog("Script attempted to reference a nonexistent paldata!\n");
3344 if(what)
3345 Z_scripterrlog("You were trying to reference the '%s' of a paldata with UID = %ld\n", what, ref);
3346 else
3347 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3348 return NULL;
3349 }
3350
3351 bottletype *checkBottleData(int32_t ref, const char *what, bool skipError = false)
3352 {
3353 if(ref > 0 && ref <= 64)
3354 {
3355 return &QMisc.bottle_types[ref-1];
3356 }
3357 if(skipError) return NULL;
3358 Z_scripterrlog("Script attempted to reference a nonexistent BottleData!\n");
3359 Z_scripterrlog("You were trying to reference the '%s' of a BottleData with UID = %ld\n", what, ref);
3360 return NULL;
3361 }
3362
3363 bottleshoptype *checkBottleShopData(int32_t ref, const char *what, bool skipError = false)
3364 {
3365 if(ref > 0 && ref <= 256)
3366 {
3367 return &QMisc.bottle_shop_types[ref-1];
3368 }
3369 if(skipError) return NULL;
3370 Z_scripterrlog("Script attempted to reference a nonexistent BottleShopData!\n");
3371 Z_scripterrlog("You were trying to reference the '%s' of a BottleShopData with UID = %ld\n", what, ref);
3372 return NULL;
3373 }
3374
3375 646718 user_bitmap *checkBitmap(int32_t ref, const char *what, bool req_valid = false, bool skipError = false)
3376 {
3377 646718 int32_t ind = ref - 10;
3378
2/4
✓ Branch 0 taken 646718 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 646718 times.
646718 if(ind >= firstUserGeneratedBitmap && ind < MAX_USER_BITMAPS)
3379 {
3380 646718 user_bitmap* b = &(scb.script_created_bitmaps[ind]);
3381
1/2
✓ Branch 0 taken 646718 times.
✗ Branch 1 not taken.
646718 if(b->reserved())
3382 {
3383
3/4
✓ Branch 0 taken 616532 times.
✓ Branch 1 taken 30186 times.
✓ Branch 2 taken 616532 times.
✗ Branch 3 not taken.
646718 if(req_valid && !b->u_bmp)
3384 {
3385 if(skipError) return NULL;
3386 Z_scripterrlog("Script attempted to reference an invalid bitmap!\n");
3387 Z_scripterrlog("Bitmap with UID = %ld does not have a valid memory bitmap!\n",ref);
3388 Z_scripterrlog("Use '->Create()' to create a memory bitmap.\n");
3389 return NULL;
3390 }
3391 646718 return b;
3392 }
3393 }
3394 else
3395 {
3396 switch(ind)
3397 {
3398 case rtSCREEN:
3399 case rtBMP0:
3400 case rtBMP1:
3401 case rtBMP2:
3402 case rtBMP3:
3403 case rtBMP4:
3404 case rtBMP5:
3405 case rtBMP6:
3406 zprint2("Internal error: 'checkBitmap()' recieved ref pointing to system bitmap!\n");
3407 zprint2("Please report this as a bug!\n");
3408 break;
3409 }
3410 }
3411 if(skipError) return NULL;
3412 Z_scripterrlog("Script attempted to reference a nonexistent bitmap!\n");
3413 if(what)
3414 Z_scripterrlog("You were trying to reference the '%s' of a bitmap with UID = %ld\n", what, ref);
3415 else
3416 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3417 return NULL;
3418 646718 }
3419
3420 int32_t get_screen_d(int32_t index1, int32_t index2)
3421 {
3422 if(index2 < 0 || index2 > 7)
3423 {
3424 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", index1);
3425 return 0;
3426 }
3427
3428 return game->screen_d[index1][index2];
3429 }
3430
3431 void set_screen_d(int32_t index1, int32_t index2, int32_t val)
3432 {
3433 if(index2 < 0 || index2 > 7)
3434 {
3435 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", index1);
3436 return;
3437 }
3438
3439 game->screen_d[index1][index2] = val;
3440 }
3441
3442 // If scr is currently being used as a layer, return that layer no.
3443 39845144 int32_t whichlayer(int32_t scr)
3444 {
3445
2/2
✓ Branch 0 taken 198687540 times.
✓ Branch 1 taken 28204008 times.
226891548 for(int32_t i = 0; i < 6; i++)
3446 {
3447
2/2
✓ Branch 0 taken 11641136 times.
✓ Branch 1 taken 187046404 times.
198687540 if(scr == (tmpscr->layermap[i] - 1) * MAPSCRS + tmpscr->layerscreen[i])
3448 11641136 return i;
3449 187046404 }
3450
3451 28204008 return -1;
3452 39845144 }
3453
3454 sprite *s;
3455
3456 int32_t item_flag(int32_t flag)
3457 {
3458 if(unsigned(ri->idata) >= MAXITEMS)
3459 {
3460 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
3461 return 0;
3462 }
3463 return (itemsbuf[ri->idata].flags & flag) ? 10000 : 0;
3464 }
3465 void item_flag(int32_t flag, bool val)
3466 {
3467 if(unsigned(ri->idata) >= MAXITEMS)
3468 {
3469 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
3470 return;
3471 }
3472 SETFLAG(itemsbuf[ri->idata].flags, flag, val);
3473 }
3474
3475 //Forward decl
3476 int32_t do_msgheight(int32_t msg, char const* str);
3477 int32_t do_msgwidth(int32_t msg, char const* str);
3478 //
3479
3480 int32_t earlyretval = -1;
3481 2767179039 int32_t get_register(const int32_t arg)
3482 {
3483 2767179039 int32_t ret = 0;
3484
3485 //Macros
3486
3487 #define GET_SPRITEDATA_VAR_INT(member, str) \
3488 { \
3489 if(unsigned(ri->spritesref) > (MAXWPNS-1) ) \
3490 { \
3491 ret = -10000; \
3492 Z_scripterrlog("Invalid Sprite ID passed to spritedata->%s: %d\n", str, (ri->spritesref*10000));\
3493 } \
3494 else \
3495 ret = (wpnsbuf[ri->spritesref].member * 10000); \
3496 }
3497
3498
357/1267
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4436597 times.
✓ Branch 4 taken 468471068 times.
✓ Branch 5 taken 1183551 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 8343964 times.
✓ Branch 8 taken 7892558 times.
✓ Branch 9 taken 35 times.
✓ Branch 10 taken 35 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 35 times.
✓ Branch 13 taken 35 times.
✓ Branch 14 taken 2177905 times.
✓ Branch 15 taken 103 times.
✓ Branch 16 taken 98 times.
✓ Branch 17 taken 2593791 times.
✓ Branch 18 taken 2594062 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 1282 times.
✓ Branch 21 taken 641181 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 765420 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 15443291 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 2112268 times.
✓ Branch 29 taken 655866 times.
✓ Branch 30 taken 552028 times.
✓ Branch 31 taken 44796049 times.
✓ Branch 32 taken 17 times.
✓ Branch 33 taken 19615159 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 5424 times.
✓ Branch 36 taken 801723 times.
✓ Branch 37 taken 557644 times.
✓ Branch 38 taken 623338 times.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 280566 times.
✓ Branch 43 taken 481556 times.
✗ Branch 44 not taken.
✓ Branch 45 taken 6213788 times.
✗ Branch 46 not taken.
✓ Branch 47 taken 206522 times.
✓ Branch 48 taken 206522 times.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✓ Branch 53 taken 206547 times.
✓ Branch 54 taken 206547 times.
✓ Branch 55 taken 173466 times.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✓ Branch 58 taken 4636 times.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✓ Branch 68 taken 2 times.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✓ Branch 71 taken 19671 times.
✓ Branch 72 taken 20320 times.
✓ Branch 73 taken 12319 times.
✓ Branch 74 taken 13864 times.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✓ Branch 77 taken 9024 times.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✗ Branch 80 not taken.
✗ Branch 81 not taken.
✓ Branch 82 taken 88721 times.
✗ Branch 83 not taken.
✗ Branch 84 not taken.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
✓ Branch 87 taken 561 times.
✗ Branch 88 not taken.
✗ Branch 89 not taken.
✗ Branch 90 not taken.
✗ Branch 91 not taken.
✗ Branch 92 not taken.
✗ Branch 93 not taken.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✗ Branch 96 not taken.
✗ Branch 97 not taken.
✗ Branch 98 not taken.
✗ Branch 99 not taken.
✗ Branch 100 not taken.
✗ Branch 101 not taken.
✗ Branch 102 not taken.
✓ Branch 103 taken 92884 times.
✓ Branch 104 taken 4123 times.
✓ Branch 105 taken 1334804 times.
✓ Branch 106 taken 847912 times.
✓ Branch 107 taken 1328070 times.
✓ Branch 108 taken 1370269 times.
✓ Branch 109 taken 5693944 times.
✓ Branch 110 taken 5182994 times.
✓ Branch 111 taken 3135646 times.
✓ Branch 112 taken 3131387 times.
✓ Branch 113 taken 119289 times.
✓ Branch 114 taken 119580 times.
✓ Branch 115 taken 23391 times.
✓ Branch 116 taken 23391 times.
✗ Branch 117 not taken.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✗ Branch 120 not taken.
✓ Branch 121 taken 766680 times.
✗ Branch 122 not taken.
✓ Branch 123 taken 1041016 times.
✓ Branch 124 taken 728101 times.
✓ Branch 125 taken 276546 times.
✓ Branch 126 taken 776094 times.
✓ Branch 127 taken 715737 times.
✓ Branch 128 taken 557304 times.
✓ Branch 129 taken 514964 times.
✓ Branch 130 taken 1875584 times.
✓ Branch 131 taken 1726419 times.
✓ Branch 132 taken 1861217 times.
✓ Branch 133 taken 1691656 times.
✓ Branch 134 taken 873882 times.
✓ Branch 135 taken 873847 times.
✓ Branch 136 taken 541201 times.
✓ Branch 137 taken 541201 times.
✗ Branch 138 not taken.
✗ Branch 139 not taken.
✗ Branch 140 not taken.
✗ Branch 141 not taken.
✓ Branch 142 taken 14 times.
✓ Branch 143 taken 3743 times.
✓ Branch 144 taken 213 times.
✗ Branch 145 not taken.
✗ Branch 146 not taken.
✓ Branch 147 taken 1121 times.
✓ Branch 148 taken 6774 times.
✗ Branch 149 not taken.
✗ Branch 150 not taken.
✗ Branch 151 not taken.
✗ Branch 152 not taken.
✗ Branch 153 not taken.
✓ Branch 154 taken 5848 times.
✗ Branch 155 not taken.
✓ Branch 156 taken 24 times.
✗ Branch 157 not taken.
✗ Branch 158 not taken.
✗ Branch 159 not taken.
✗ Branch 160 not taken.
✓ Branch 161 taken 4206 times.
✓ Branch 162 taken 5084 times.
✓ Branch 163 taken 114 times.
✗ Branch 164 not taken.
✗ Branch 165 not taken.
✗ Branch 166 not taken.
✓ Branch 167 taken 117090 times.
✓ Branch 168 taken 7933 times.
✗ Branch 169 not taken.
✗ Branch 170 not taken.
✗ Branch 171 not taken.
✗ Branch 172 not taken.
✗ Branch 173 not taken.
✓ Branch 174 taken 18 times.
✓ Branch 175 taken 7933 times.
✗ Branch 176 not taken.
✗ Branch 177 not taken.
✗ Branch 178 not taken.
✗ Branch 179 not taken.
✗ Branch 180 not taken.
✗ Branch 181 not taken.
✗ Branch 182 not taken.
✗ Branch 183 not taken.
✓ Branch 184 taken 2552 times.
✓ Branch 185 taken 2552 times.
✓ Branch 186 taken 6 times.
✓ Branch 187 taken 334 times.
✗ Branch 188 not taken.
✗ Branch 189 not taken.
✗ Branch 190 not taken.
✓ Branch 191 taken 2552 times.
✓ Branch 192 taken 2552 times.
✓ Branch 193 taken 2542 times.
✓ Branch 194 taken 1300 times.
✓ Branch 195 taken 1300 times.
✓ Branch 196 taken 685905 times.
✗ Branch 197 not taken.
✗ Branch 198 not taken.
✓ Branch 199 taken 19906 times.
✓ Branch 200 taken 108294 times.
✗ Branch 201 not taken.
✗ Branch 202 not taken.
✗ Branch 203 not taken.
✗ Branch 204 not taken.
✗ Branch 205 not taken.
✗ Branch 206 not taken.
✗ Branch 207 not taken.
✗ Branch 208 not taken.
✗ Branch 209 not taken.
✗ Branch 210 not taken.
✗ Branch 211 not taken.
✗ Branch 212 not taken.
✗ Branch 213 not taken.
✗ Branch 214 not taken.
✗ Branch 215 not taken.
✗ Branch 216 not taken.
✗ Branch 217 not taken.
✗ Branch 218 not taken.
✗ Branch 219 not taken.
✗ Branch 220 not taken.
✗ Branch 221 not taken.
✗ Branch 222 not taken.
✗ Branch 223 not taken.
✗ Branch 224 not taken.
✗ Branch 225 not taken.
✗ Branch 226 not taken.
✗ Branch 227 not taken.
✗ Branch 228 not taken.
✗ Branch 229 not taken.
✗ Branch 230 not taken.
✗ Branch 231 not taken.
✗ Branch 232 not taken.
✗ Branch 233 not taken.
✗ Branch 234 not taken.
✗ Branch 235 not taken.
✗ Branch 236 not taken.
✗ Branch 237 not taken.
✗ Branch 238 not taken.
✗ Branch 239 not taken.
✗ Branch 240 not taken.
✗ Branch 241 not taken.
✗ Branch 242 not taken.
✗ Branch 243 not taken.
✓ Branch 244 taken 713905 times.
✗ Branch 245 not taken.
✓ Branch 246 taken 709431 times.
✓ Branch 247 taken 55748 times.
✗ Branch 248 not taken.
✗ Branch 249 not taken.
✓ Branch 250 taken 67683 times.
✗ Branch 251 not taken.
✓ Branch 252 taken 1329 times.
✓ Branch 253 taken 2 times.
✗ Branch 254 not taken.
✗ Branch 255 not taken.
✗ Branch 256 not taken.
✗ Branch 257 not taken.
✗ Branch 258 not taken.
✗ Branch 259 not taken.
✗ Branch 260 not taken.
✓ Branch 261 taken 85830 times.
✓ Branch 262 taken 1122 times.
✓ Branch 263 taken 3785245 times.
✓ Branch 264 taken 49772 times.
✗ Branch 265 not taken.
✗ Branch 266 not taken.
✓ Branch 267 taken 49794 times.
✗ Branch 268 not taken.
✓ Branch 269 taken 3289 times.
✗ Branch 270 not taken.
✓ Branch 271 taken 3289 times.
✗ Branch 272 not taken.
✗ Branch 273 not taken.
✓ Branch 274 taken 1094820 times.
✗ Branch 275 not taken.
✓ Branch 276 taken 830567 times.
✗ Branch 277 not taken.
✓ Branch 278 taken 135142 times.
✓ Branch 279 taken 132394 times.
✗ Branch 280 not taken.
✗ Branch 281 not taken.
✗ Branch 282 not taken.
✗ Branch 283 not taken.
✗ Branch 284 not taken.
✗ Branch 285 not taken.
✓ Branch 286 taken 133136 times.
✓ Branch 287 taken 135091 times.
✓ Branch 288 taken 27874 times.
✓ Branch 289 taken 25249 times.
✓ Branch 290 taken 25249 times.
✓ Branch 291 taken 1553638 times.
✓ Branch 292 taken 4320 times.
✗ Branch 293 not taken.
✗ Branch 294 not taken.
✗ Branch 295 not taken.
✗ Branch 296 not taken.
✓ Branch 297 taken 179 times.
✗ Branch 298 not taken.
✓ Branch 299 taken 180 times.
✗ Branch 300 not taken.
✗ Branch 301 not taken.
✗ Branch 302 not taken.
✗ Branch 303 not taken.
✗ Branch 304 not taken.
✗ Branch 305 not taken.
✗ Branch 306 not taken.
✗ Branch 307 not taken.
✗ Branch 308 not taken.
✗ Branch 309 not taken.
✗ Branch 310 not taken.
✗ Branch 311 not taken.
✗ Branch 312 not taken.
✗ Branch 313 not taken.
✗ Branch 314 not taken.
✗ Branch 315 not taken.
✗ Branch 316 not taken.
✗ Branch 317 not taken.
✗ Branch 318 not taken.
✗ Branch 319 not taken.
✗ Branch 320 not taken.
✗ Branch 321 not taken.
✗ Branch 322 not taken.
✓ Branch 323 taken 1266708 times.
✓ Branch 324 taken 63485 times.
✗ Branch 325 not taken.
✗ Branch 326 not taken.
✓ Branch 327 taken 22679 times.
✗ Branch 328 not taken.
✗ Branch 329 not taken.
✓ Branch 330 taken 362690 times.
✓ Branch 331 taken 373525 times.
✗ Branch 332 not taken.
✗ Branch 333 not taken.
✗ Branch 334 not taken.
✓ Branch 335 taken 68688 times.
✗ Branch 336 not taken.
✗ Branch 337 not taken.
✓ Branch 338 taken 46359 times.
✓ Branch 339 taken 90188 times.
✓ Branch 340 taken 154 times.
✓ Branch 341 taken 2150394 times.
✓ Branch 342 taken 106032 times.
✗ Branch 343 not taken.
✗ Branch 344 not taken.
✓ Branch 345 taken 24909 times.
✗ Branch 346 not taken.
✓ Branch 347 taken 70 times.
✗ Branch 348 not taken.
✓ Branch 349 taken 70 times.
✗ Branch 350 not taken.
✗ Branch 351 not taken.
✓ Branch 352 taken 1911946 times.
✗ Branch 353 not taken.
✓ Branch 354 taken 2925 times.
✗ Branch 355 not taken.
✓ Branch 356 taken 65540 times.
✓ Branch 357 taken 65540 times.
✓ Branch 358 taken 8 times.
✓ Branch 359 taken 96 times.
✗ Branch 360 not taken.
✗ Branch 361 not taken.
✗ Branch 362 not taken.
✗ Branch 363 not taken.
✓ Branch 364 taken 62523 times.
✓ Branch 365 taken 62523 times.
✓ Branch 366 taken 12470 times.
✓ Branch 367 taken 24497 times.
✓ Branch 368 taken 24497 times.
✓ Branch 369 taken 13780500 times.
✗ Branch 370 not taken.
✗ Branch 371 not taken.
✗ Branch 372 not taken.
✗ Branch 373 not taken.
✗ Branch 374 not taken.
✗ Branch 375 not taken.
✓ Branch 376 taken 16680 times.
✗ Branch 377 not taken.
✗ Branch 378 not taken.
✗ Branch 379 not taken.
✗ Branch 380 not taken.
✗ Branch 381 not taken.
✗ Branch 382 not taken.
✗ Branch 383 not taken.
✗ Branch 384 not taken.
✗ Branch 385 not taken.
✗ Branch 386 not taken.
✗ Branch 387 not taken.
✗ Branch 388 not taken.
✗ Branch 389 not taken.
✗ Branch 390 not taken.
✗ Branch 391 not taken.
✗ Branch 392 not taken.
✗ Branch 393 not taken.
✗ Branch 394 not taken.
✗ Branch 395 not taken.
✗ Branch 396 not taken.
✗ Branch 397 not taken.
✗ Branch 398 not taken.
✗ Branch 399 not taken.
✗ Branch 400 not taken.
✗ Branch 401 not taken.
✗ Branch 402 not taken.
✗ Branch 403 not taken.
✗ Branch 404 not taken.
✗ Branch 405 not taken.
✗ Branch 406 not taken.
✗ Branch 407 not taken.
✓ Branch 408 taken 2103 times.
✗ Branch 409 not taken.
✓ Branch 410 taken 2103 times.
✗ Branch 411 not taken.
✗ Branch 412 not taken.
✗ Branch 413 not taken.
✗ Branch 414 not taken.
✓ Branch 415 taken 17 times.
✓ Branch 416 taken 26 times.
✓ Branch 417 taken 678 times.
✓ Branch 418 taken 972 times.
✓ Branch 419 taken 14 times.
✓ Branch 420 taken 471 times.
✓ Branch 421 taken 4033084 times.
✓ Branch 422 taken 1608203 times.
✓ Branch 423 taken 15 times.
✓ Branch 424 taken 856 times.
✗ Branch 425 not taken.
✗ Branch 426 not taken.
✓ Branch 427 taken 700 times.
✓ Branch 428 taken 2369090 times.
✗ Branch 429 not taken.
✓ Branch 430 taken 561833 times.
✗ Branch 431 not taken.
✗ Branch 432 not taken.
✗ Branch 433 not taken.
✓ Branch 434 taken 225833 times.
✗ Branch 435 not taken.
✗ Branch 436 not taken.
✗ Branch 437 not taken.
✗ Branch 438 not taken.
✓ Branch 439 taken 22596070 times.
✓ Branch 440 taken 14112447 times.
✓ Branch 441 taken 125 times.
✓ Branch 442 taken 63717 times.
✗ Branch 443 not taken.
✗ Branch 444 not taken.
✓ Branch 445 taken 49232485 times.
✓ Branch 446 taken 14025143 times.
✗ Branch 447 not taken.
✗ Branch 448 not taken.
✗ Branch 449 not taken.
✗ Branch 450 not taken.
✗ Branch 451 not taken.
✗ Branch 452 not taken.
✗ Branch 453 not taken.
✗ Branch 454 not taken.
✗ Branch 455 not taken.
✗ Branch 456 not taken.
✗ Branch 457 not taken.
✗ Branch 458 not taken.
✗ Branch 459 not taken.
✗ Branch 460 not taken.
✗ Branch 461 not taken.
✗ Branch 462 not taken.
✓ Branch 463 taken 515 times.
✗ Branch 464 not taken.
✗ Branch 465 not taken.
✗ Branch 466 not taken.
✗ Branch 467 not taken.
✗ Branch 468 not taken.
✗ Branch 469 not taken.
✗ Branch 470 not taken.
✗ Branch 471 not taken.
✗ Branch 472 not taken.
✗ Branch 473 not taken.
✗ Branch 474 not taken.
✗ Branch 475 not taken.
✗ Branch 476 not taken.
✗ Branch 477 not taken.
✗ Branch 478 not taken.
✗ Branch 479 not taken.
✗ Branch 480 not taken.
✗ Branch 481 not taken.
✗ Branch 482 not taken.
✗ Branch 483 not taken.
✗ Branch 484 not taken.
✗ Branch 485 not taken.
✗ Branch 486 not taken.
✓ Branch 487 taken 109824 times.
✗ Branch 488 not taken.
✗ Branch 489 not taken.
✗ Branch 490 not taken.
✗ Branch 491 not taken.
✗ Branch 492 not taken.
✗ Branch 493 not taken.
✗ Branch 494 not taken.
✗ Branch 495 not taken.
✗ Branch 496 not taken.
✗ Branch 497 not taken.
✗ Branch 498 not taken.
✗ Branch 499 not taken.
✗ Branch 500 not taken.
✓ Branch 501 taken 1 times.
✗ Branch 502 not taken.
✗ Branch 503 not taken.
✗ Branch 504 not taken.
✓ Branch 505 taken 910 times.
✓ Branch 506 taken 43250 times.
✗ Branch 507 not taken.
✓ Branch 508 taken 3 times.
✓ Branch 509 taken 4 times.
✗ Branch 510 not taken.
✗ Branch 511 not taken.
✗ Branch 512 not taken.
✗ Branch 513 not taken.
✗ Branch 514 not taken.
✗ Branch 515 not taken.
✗ Branch 516 not taken.
✗ Branch 517 not taken.
✗ Branch 518 not taken.
✗ Branch 519 not taken.
✗ Branch 520 not taken.
✗ Branch 521 not taken.
✗ Branch 522 not taken.
✗ Branch 523 not taken.
✗ Branch 524 not taken.
✓ Branch 525 taken 10246 times.
✓ Branch 526 taken 7214 times.
✓ Branch 527 taken 2272 times.
✓ Branch 528 taken 6637837 times.
✓ Branch 529 taken 1522704 times.
✓ Branch 530 taken 11316803 times.
✗ Branch 531 not taken.
✗ Branch 532 not taken.
✗ Branch 533 not taken.
✗ Branch 534 not taken.
✓ Branch 535 taken 1 times.
✓ Branch 536 taken 1 times.
✗ Branch 537 not taken.
✗ Branch 538 not taken.
✗ Branch 539 not taken.
✗ Branch 540 not taken.
✗ Branch 541 not taken.
✗ Branch 542 not taken.
✗ Branch 543 not taken.
✗ Branch 544 not taken.
✓ Branch 545 taken 6554876 times.
✗ Branch 546 not taken.
✗ Branch 547 not taken.
✓ Branch 548 taken 3670 times.
✗ Branch 549 not taken.
✗ Branch 550 not taken.
✗ Branch 551 not taken.
✗ Branch 552 not taken.
✓ Branch 553 taken 701 times.
✓ Branch 554 taken 213 times.
✗ Branch 555 not taken.
✓ Branch 556 taken 6 times.
✗ Branch 557 not taken.
✓ Branch 558 taken 192 times.
✓ Branch 559 taken 19 times.
✗ Branch 560 not taken.
✗ Branch 561 not taken.
✓ Branch 562 taken 1124 times.
✓ Branch 563 taken 733036 times.
✗ Branch 564 not taken.
✗ Branch 565 not taken.
✗ Branch 566 not taken.
✗ Branch 567 not taken.
✗ Branch 568 not taken.
✗ Branch 569 not taken.
✗ Branch 570 not taken.
✗ Branch 571 not taken.
✗ Branch 572 not taken.
✗ Branch 573 not taken.
✗ Branch 574 not taken.
✓ Branch 575 taken 22016 times.
✗ Branch 576 not taken.
✗ Branch 577 not taken.
✗ Branch 578 not taken.
✗ Branch 579 not taken.
✗ Branch 580 not taken.
✓ Branch 581 taken 10673 times.
✗ Branch 582 not taken.
✗ Branch 583 not taken.
✗ Branch 584 not taken.
✗ Branch 585 not taken.
✗ Branch 586 not taken.
✗ Branch 587 not taken.
✓ Branch 588 taken 15656 times.
✓ Branch 589 taken 158257 times.
✓ Branch 590 taken 1817944 times.
✓ Branch 591 taken 1340238 times.
✓ Branch 592 taken 2886839 times.
✓ Branch 593 taken 15644160 times.
✗ Branch 594 not taken.
✗ Branch 595 not taken.
✓ Branch 596 taken 25786 times.
✓ Branch 597 taken 16 times.
✗ Branch 598 not taken.
✗ Branch 599 not taken.
✓ Branch 600 taken 800741 times.
✗ Branch 601 not taken.
✗ Branch 602 not taken.
✗ Branch 603 not taken.
✗ Branch 604 not taken.
✗ Branch 605 not taken.
✗ Branch 606 not taken.
✓ Branch 607 taken 427 times.
✗ Branch 608 not taken.
✗ Branch 609 not taken.
✗ Branch 610 not taken.
✗ Branch 611 not taken.
✗ Branch 612 not taken.
✗ Branch 613 not taken.
✗ Branch 614 not taken.
✗ Branch 615 not taken.
✗ Branch 616 not taken.
✗ Branch 617 not taken.
✗ Branch 618 not taken.
✗ Branch 619 not taken.
✗ Branch 620 not taken.
✗ Branch 621 not taken.
✗ Branch 622 not taken.
✗ Branch 623 not taken.
✗ Branch 624 not taken.
✗ Branch 625 not taken.
✗ Branch 626 not taken.
✗ Branch 627 not taken.
✗ Branch 628 not taken.
✗ Branch 629 not taken.
✗ Branch 630 not taken.
✗ Branch 631 not taken.
✗ Branch 632 not taken.
✗ Branch 633 not taken.
✗ Branch 634 not taken.
✗ Branch 635 not taken.
✗ Branch 636 not taken.
✗ Branch 637 not taken.
✗ Branch 638 not taken.
✗ Branch 639 not taken.
✗ Branch 640 not taken.
✗ Branch 641 not taken.
✗ Branch 642 not taken.
✗ Branch 643 not taken.
✗ Branch 644 not taken.
✗ Branch 645 not taken.
✗ Branch 646 not taken.
✗ Branch 647 not taken.
✗ Branch 648 not taken.
✗ Branch 649 not taken.
✗ Branch 650 not taken.
✗ Branch 651 not taken.
✗ Branch 652 not taken.
✗ Branch 653 not taken.
✗ Branch 654 not taken.
✗ Branch 655 not taken.
✗ Branch 656 not taken.
✗ Branch 657 not taken.
✗ Branch 658 not taken.
✗ Branch 659 not taken.
✗ Branch 660 not taken.
✓ Branch 661 taken 952310006 times.
✗ Branch 662 not taken.
✓ Branch 663 taken 751837446 times.
✗ Branch 664 not taken.
✓ Branch 665 taken 6076 times.
✓ Branch 666 taken 28819 times.
✓ Branch 667 taken 15044371 times.
✓ Branch 668 taken 14902357 times.
✓ Branch 669 taken 564437 times.
✗ Branch 670 not taken.
✓ Branch 671 taken 2929 times.
✗ Branch 672 not taken.
✗ Branch 673 not taken.
✓ Branch 674 taken 2402 times.
✗ Branch 675 not taken.
✗ Branch 676 not taken.
✗ Branch 677 not taken.
✗ Branch 678 not taken.
✗ Branch 679 not taken.
✓ Branch 680 taken 766680 times.
✗ Branch 681 not taken.
✓ Branch 682 taken 468 times.
✗ Branch 683 not taken.
✗ Branch 684 not taken.
✗ Branch 685 not taken.
✗ Branch 686 not taken.
✗ Branch 687 not taken.
✗ Branch 688 not taken.
✗ Branch 689 not taken.
✗ Branch 690 not taken.
✗ Branch 691 not taken.
✗ Branch 692 not taken.
✗ Branch 693 not taken.
✗ Branch 694 not taken.
✗ Branch 695 not taken.
✗ Branch 696 not taken.
✗ Branch 697 not taken.
✗ Branch 698 not taken.
✗ Branch 699 not taken.
✗ Branch 700 not taken.
✗ Branch 701 not taken.
✗ Branch 702 not taken.
✗ Branch 703 not taken.
✗ Branch 704 not taken.
✗ Branch 705 not taken.
✗ Branch 706 not taken.
✗ Branch 707 not taken.
✗ Branch 708 not taken.
✗ Branch 709 not taken.
✗ Branch 710 not taken.
✗ Branch 711 not taken.
✗ Branch 712 not taken.
✓ Branch 713 taken 53 times.
✗ Branch 714 not taken.
✗ Branch 715 not taken.
✗ Branch 716 not taken.
✗ Branch 717 not taken.
✗ Branch 718 not taken.
✓ Branch 719 taken 1751295 times.
✓ Branch 720 taken 14532 times.
✗ Branch 721 not taken.
✗ Branch 722 not taken.
✗ Branch 723 not taken.
✗ Branch 724 not taken.
✗ Branch 725 not taken.
✗ Branch 726 not taken.
✗ Branch 727 not taken.
✗ Branch 728 not taken.
✓ Branch 729 taken 140 times.
✓ Branch 730 taken 1765 times.
✗ Branch 731 not taken.
✗ Branch 732 not taken.
✗ Branch 733 not taken.
✗ Branch 734 not taken.
✗ Branch 735 not taken.
✗ Branch 736 not taken.
✗ Branch 737 not taken.
✗ Branch 738 not taken.
✗ Branch 739 not taken.
✗ Branch 740 not taken.
✗ Branch 741 not taken.
✗ Branch 742 not taken.
✗ Branch 743 not taken.
✓ Branch 744 taken 55501 times.
✗ Branch 745 not taken.
✓ Branch 746 taken 55501 times.
✓ Branch 747 taken 63041 times.
✓ Branch 748 taken 142873 times.
✓ Branch 749 taken 74538 times.
✗ Branch 750 not taken.
✗ Branch 751 not taken.
✓ Branch 752 taken 77690 times.
✗ Branch 753 not taken.
✗ Branch 754 not taken.
✗ Branch 755 not taken.
✗ Branch 756 not taken.
✗ Branch 757 not taken.
✗ Branch 758 not taken.
✓ Branch 759 taken 426414 times.
✓ Branch 760 taken 436097 times.
✗ Branch 761 not taken.
✓ Branch 762 taken 410674 times.
✗ Branch 763 not taken.
✗ Branch 764 not taken.
✓ Branch 765 taken 5123278 times.
✗ Branch 766 not taken.
✓ Branch 767 taken 165739 times.
✗ Branch 768 not taken.
✓ Branch 769 taken 1128791 times.
✓ Branch 770 taken 472577 times.
✗ Branch 771 not taken.
✓ Branch 772 taken 532410 times.
✓ Branch 773 taken 3169 times.
✓ Branch 774 taken 13200 times.
✓ Branch 775 taken 5408 times.
✓ Branch 776 taken 39139 times.
✗ Branch 777 not taken.
✗ Branch 778 not taken.
✓ Branch 779 taken 404 times.
✗ Branch 780 not taken.
✓ Branch 781 taken 17986 times.
✗ Branch 782 not taken.
✗ Branch 783 not taken.
✓ Branch 784 taken 6086 times.
✓ Branch 785 taken 383015 times.
✓ Branch 786 taken 383015 times.
✓ Branch 787 taken 427914 times.
✓ Branch 788 taken 427914 times.
✓ Branch 789 taken 226198 times.
✗ Branch 790 not taken.
✓ Branch 791 taken 1504060 times.
✓ Branch 792 taken 1486185 times.
✓ Branch 793 taken 1058431 times.
✗ Branch 794 not taken.
✓ Branch 795 taken 1035972 times.
✓ Branch 796 taken 603413 times.
✓ Branch 797 taken 2061476 times.
✓ Branch 798 taken 2062453 times.
✗ Branch 799 not taken.
✗ Branch 800 not taken.
✗ Branch 801 not taken.
✓ Branch 802 taken 2061449 times.
✓ Branch 803 taken 75622 times.
✗ Branch 804 not taken.
✗ Branch 805 not taken.
✗ Branch 806 not taken.
✗ Branch 807 not taken.
✗ Branch 808 not taken.
✗ Branch 809 not taken.
✓ Branch 810 taken 527244 times.
✗ Branch 811 not taken.
✓ Branch 812 taken 22516459 times.
✗ Branch 813 not taken.
✓ Branch 814 taken 598 times.
✗ Branch 815 not taken.
✓ Branch 816 taken 3670410 times.
✓ Branch 817 taken 167669 times.
✓ Branch 818 taken 268246 times.
✗ Branch 819 not taken.
✓ Branch 820 taken 11380654 times.
✗ Branch 821 not taken.
✗ Branch 822 not taken.
✓ Branch 823 taken 6431340 times.
✗ Branch 824 not taken.
✗ Branch 825 not taken.
✗ Branch 826 not taken.
✗ Branch 827 not taken.
✗ Branch 828 not taken.
✗ Branch 829 not taken.
✗ Branch 830 not taken.
✗ Branch 831 not taken.
✗ Branch 832 not taken.
✗ Branch 833 not taken.
✗ Branch 834 not taken.
✗ Branch 835 not taken.
✗ Branch 836 not taken.
✓ Branch 837 taken 1267145 times.
✓ Branch 838 taken 218 times.
✗ Branch 839 not taken.
✗ Branch 840 not taken.
✗ Branch 841 not taken.
✗ Branch 842 not taken.
✗ Branch 843 not taken.
✗ Branch 844 not taken.
✗ Branch 845 not taken.
✗ Branch 846 not taken.
✗ Branch 847 not taken.
✓ Branch 848 taken 191517 times.
✓ Branch 849 taken 1218351 times.
✗ Branch 850 not taken.
✗ Branch 851 not taken.
✗ Branch 852 not taken.
✓ Branch 853 taken 18739404 times.
✓ Branch 854 taken 5921351 times.
✗ Branch 855 not taken.
✗ Branch 856 not taken.
✗ Branch 857 not taken.
✗ Branch 858 not taken.
✗ Branch 859 not taken.
✗ Branch 860 not taken.
✗ Branch 861 not taken.
✗ Branch 862 not taken.
✗ Branch 863 not taken.
✗ Branch 864 not taken.
✓ Branch 865 taken 1764243 times.
✓ Branch 866 taken 1019 times.
✓ Branch 867 taken 255560 times.
✗ Branch 868 not taken.
✓ Branch 869 taken 741668 times.
✓ Branch 870 taken 96115 times.
✓ Branch 871 taken 9482 times.
✓ Branch 872 taken 37 times.
✓ Branch 873 taken 27341446 times.
✓ Branch 874 taken 2709583 times.
✓ Branch 875 taken 3906008 times.
✓ Branch 876 taken 26493228 times.
✓ Branch 877 taken 2974800 times.
✓ Branch 878 taken 96784 times.
✗ Branch 879 not taken.
✓ Branch 880 taken 13758809 times.
✓ Branch 881 taken 2272124 times.
✓ Branch 882 taken 5866709 times.
✓ Branch 883 taken 449777 times.
✓ Branch 884 taken 421915 times.
✓ Branch 885 taken 6342577 times.
✗ Branch 886 not taken.
✓ Branch 887 taken 54 times.
✗ Branch 888 not taken.
✗ Branch 889 not taken.
✗ Branch 890 not taken.
✗ Branch 891 not taken.
✗ Branch 892 not taken.
✗ Branch 893 not taken.
✗ Branch 894 not taken.
✗ Branch 895 not taken.
✗ Branch 896 not taken.
✗ Branch 897 not taken.
✗ Branch 898 not taken.
✗ Branch 899 not taken.
✗ Branch 900 not taken.
✓ Branch 901 taken 390022 times.
✗ Branch 902 not taken.
✗ Branch 903 not taken.
✗ Branch 904 not taken.
✓ Branch 905 taken 229939 times.
✓ Branch 906 taken 91 times.
✗ Branch 907 not taken.
✗ Branch 908 not taken.
✓ Branch 909 taken 16 times.
✗ Branch 910 not taken.
✓ Branch 911 taken 16 times.
✗ Branch 912 not taken.
✓ Branch 913 taken 16 times.
✓ Branch 914 taken 16 times.
✗ Branch 915 not taken.
✗ Branch 916 not taken.
✗ Branch 917 not taken.
✓ Branch 918 taken 192 times.
✗ Branch 919 not taken.
✗ Branch 920 not taken.
✗ Branch 921 not taken.
✗ Branch 922 not taken.
✗ Branch 923 not taken.
✗ Branch 924 not taken.
✗ Branch 925 not taken.
✗ Branch 926 not taken.
✗ Branch 927 not taken.
✗ Branch 928 not taken.
✗ Branch 929 not taken.
✗ Branch 930 not taken.
✗ Branch 931 not taken.
✗ Branch 932 not taken.
✓ Branch 933 taken 192 times.
✗ Branch 934 not taken.
✗ Branch 935 not taken.
✗ Branch 936 not taken.
✗ Branch 937 not taken.
✗ Branch 938 not taken.
✗ Branch 939 not taken.
✗ Branch 940 not taken.
✗ Branch 941 not taken.
✗ Branch 942 not taken.
✗ Branch 943 not taken.
✗ Branch 944 not taken.
✗ Branch 945 not taken.
✗ Branch 946 not taken.
✗ Branch 947 not taken.
✗ Branch 948 not taken.
✗ Branch 949 not taken.
✗ Branch 950 not taken.
✗ Branch 951 not taken.
✗ Branch 952 not taken.
✗ Branch 953 not taken.
✗ Branch 954 not taken.
✓ Branch 955 taken 13 times.
✓ Branch 956 taken 13 times.
✗ Branch 957 not taken.
✗ Branch 958 not taken.
✗ Branch 959 not taken.
✗ Branch 960 not taken.
✓ Branch 961 taken 128 times.
✓ Branch 962 taken 128 times.
✓ Branch 963 taken 128 times.
✗ Branch 964 not taken.
✗ Branch 965 not taken.
✗ Branch 966 not taken.
✓ Branch 967 taken 200 times.
✓ Branch 968 taken 8 times.
✓ Branch 969 taken 5 times.
✓ Branch 970 taken 392 times.
✓ Branch 971 taken 392 times.
✓ Branch 972 taken 5 times.
✓ Branch 973 taken 5 times.
✓ Branch 974 taken 5 times.
✓ Branch 975 taken 5 times.
✓ Branch 976 taken 91 times.
✗ Branch 977 not taken.
✓ Branch 978 taken 32 times.
✗ Branch 979 not taken.
✗ Branch 980 not taken.
✗ Branch 981 not taken.
✗ Branch 982 not taken.
✓ Branch 983 taken 8 times.
✓ Branch 984 taken 8 times.
✓ Branch 985 taken 5 times.
✓ Branch 986 taken 5 times.
✗ Branch 987 not taken.
✓ Branch 988 taken 32773 times.
✓ Branch 989 taken 1800 times.
✗ Branch 990 not taken.
✗ Branch 991 not taken.
✗ Branch 992 not taken.
✗ Branch 993 not taken.
✗ Branch 994 not taken.
✗ Branch 995 not taken.
✗ Branch 996 not taken.
✗ Branch 997 not taken.
✗ Branch 998 not taken.
✗ Branch 999 not taken.
✗ Branch 1000 not taken.
✓ Branch 1001 taken 18 times.
✓ Branch 1002 taken 42 times.
✓ Branch 1003 taken 6 times.
✗ Branch 1004 not taken.
✓ Branch 1005 taken 4767952 times.
✓ Branch 1006 taken 4654485 times.
✓ Branch 1007 taken 5945377 times.
✓ Branch 1008 taken 2540907 times.
✓ Branch 1009 taken 345816 times.
✓ Branch 1010 taken 85947 times.
✗ Branch 1011 not taken.
✓ Branch 1012 taken 45056 times.
✗ Branch 1013 not taken.
✗ Branch 1014 not taken.
✗ Branch 1015 not taken.
✗ Branch 1016 not taken.
✗ Branch 1017 not taken.
✗ Branch 1018 not taken.
✗ Branch 1019 not taken.
✗ Branch 1020 not taken.
✗ Branch 1021 not taken.
✗ Branch 1022 not taken.
✓ Branch 1023 taken 43092 times.
✓ Branch 1024 taken 45 times.
✓ Branch 1025 taken 1402 times.
✓ Branch 1026 taken 17 times.
✗ Branch 1027 not taken.
✗ Branch 1028 not taken.
✗ Branch 1029 not taken.
✓ Branch 1030 taken 6 times.
✗ Branch 1031 not taken.
✗ Branch 1032 not taken.
✗ Branch 1033 not taken.
✗ Branch 1034 not taken.
✗ Branch 1035 not taken.
✗ Branch 1036 not taken.
✗ Branch 1037 not taken.
✗ Branch 1038 not taken.
✗ Branch 1039 not taken.
✗ Branch 1040 not taken.
✗ Branch 1041 not taken.
✗ Branch 1042 not taken.
✗ Branch 1043 not taken.
✗ Branch 1044 not taken.
✗ Branch 1045 not taken.
✗ Branch 1046 not taken.
✗ Branch 1047 not taken.
✗ Branch 1048 not taken.
✗ Branch 1049 not taken.
✗ Branch 1050 not taken.
✗ Branch 1051 not taken.
✗ Branch 1052 not taken.
✗ Branch 1053 not taken.
✗ Branch 1054 not taken.
✗ Branch 1055 not taken.
✗ Branch 1056 not taken.
✓ Branch 1057 taken 11261 times.
✓ Branch 1058 taken 11261 times.
✓ Branch 1059 taken 33759 times.
✓ Branch 1060 taken 11044 times.
✓ Branch 1061 taken 4546 times.
✗ Branch 1062 not taken.
✗ Branch 1063 not taken.
✗ Branch 1064 not taken.
✗ Branch 1065 not taken.
✓ Branch 1066 taken 4546 times.
✗ Branch 1067 not taken.
✗ Branch 1068 not taken.
✓ Branch 1069 taken 4890 times.
✗ Branch 1070 not taken.
✗ Branch 1071 not taken.
✓ Branch 1072 taken 22172 times.
✗ Branch 1073 not taken.
✗ Branch 1074 not taken.
✗ Branch 1075 not taken.
✗ Branch 1076 not taken.
✗ Branch 1077 not taken.
✗ Branch 1078 not taken.
✗ Branch 1079 not taken.
✗ Branch 1080 not taken.
✗ Branch 1081 not taken.
✓ Branch 1082 taken 66 times.
✓ Branch 1083 taken 1636 times.
✓ Branch 1084 taken 568 times.
✓ Branch 1085 taken 136 times.
✗ Branch 1086 not taken.
✗ Branch 1087 not taken.
✗ Branch 1088 not taken.
✗ Branch 1089 not taken.
✗ Branch 1090 not taken.
✗ Branch 1091 not taken.
✗ Branch 1092 not taken.
✗ Branch 1093 not taken.
✗ Branch 1094 not taken.
✗ Branch 1095 not taken.
✗ Branch 1096 not taken.
✗ Branch 1097 not taken.
✗ Branch 1098 not taken.
✗ Branch 1099 not taken.
✗ Branch 1100 not taken.
✗ Branch 1101 not taken.
✗ Branch 1102 not taken.
✗ Branch 1103 not taken.
✗ Branch 1104 not taken.
✗ Branch 1105 not taken.
✗ Branch 1106 not taken.
✗ Branch 1107 not taken.
✗ Branch 1108 not taken.
✗ Branch 1109 not taken.
✗ Branch 1110 not taken.
✗ Branch 1111 not taken.
✗ Branch 1112 not taken.
✗ Branch 1113 not taken.
✗ Branch 1114 not taken.
✗ Branch 1115 not taken.
✗ Branch 1116 not taken.
✗ Branch 1117 not taken.
✗ Branch 1118 not taken.
✗ Branch 1119 not taken.
✗ Branch 1120 not taken.
✗ Branch 1121 not taken.
✗ Branch 1122 not taken.
✗ Branch 1123 not taken.
✗ Branch 1124 not taken.
✗ Branch 1125 not taken.
✗ Branch 1126 not taken.
✗ Branch 1127 not taken.
✗ Branch 1128 not taken.
✗ Branch 1129 not taken.
✗ Branch 1130 not taken.
✗ Branch 1131 not taken.
✗ Branch 1132 not taken.
✗ Branch 1133 not taken.
✗ Branch 1134 not taken.
✗ Branch 1135 not taken.
✗ Branch 1136 not taken.
✗ Branch 1137 not taken.
✗ Branch 1138 not taken.
✗ Branch 1139 not taken.
✗ Branch 1140 not taken.
✗ Branch 1141 not taken.
✗ Branch 1142 not taken.
✗ Branch 1143 not taken.
✗ Branch 1144 not taken.
✗ Branch 1145 not taken.
✗ Branch 1146 not taken.
✗ Branch 1147 not taken.
✗ Branch 1148 not taken.
✗ Branch 1149 not taken.
✗ Branch 1150 not taken.
✗ Branch 1151 not taken.
✗ Branch 1152 not taken.
✗ Branch 1153 not taken.
✗ Branch 1154 not taken.
✗ Branch 1155 not taken.
✗ Branch 1156 not taken.
✗ Branch 1157 not taken.
✗ Branch 1158 not taken.
✗ Branch 1159 not taken.
✗ Branch 1160 not taken.
✗ Branch 1161 not taken.
✗ Branch 1162 not taken.
✗ Branch 1163 not taken.
✗ Branch 1164 not taken.
✗ Branch 1165 not taken.
✗ Branch 1166 not taken.
✗ Branch 1167 not taken.
✗ Branch 1168 not taken.
✗ Branch 1169 not taken.
✗ Branch 1170 not taken.
✗ Branch 1171 not taken.
✗ Branch 1172 not taken.
✗ Branch 1173 not taken.
✗ Branch 1174 not taken.
✗ Branch 1175 not taken.
✗ Branch 1176 not taken.
✗ Branch 1177 not taken.
✗ Branch 1178 not taken.
✗ Branch 1179 not taken.
✗ Branch 1180 not taken.
✗ Branch 1181 not taken.
✗ Branch 1182 not taken.
✗ Branch 1183 not taken.
✗ Branch 1184 not taken.
✗ Branch 1185 not taken.
✗ Branch 1186 not taken.
✗ Branch 1187 not taken.
✗ Branch 1188 not taken.
✗ Branch 1189 not taken.
✗ Branch 1190 not taken.
✗ Branch 1191 not taken.
✗ Branch 1192 not taken.
✗ Branch 1193 not taken.
✗ Branch 1194 not taken.
✗ Branch 1195 not taken.
✗ Branch 1196 not taken.
✗ Branch 1197 not taken.
✗ Branch 1198 not taken.
✗ Branch 1199 not taken.
✗ Branch 1200 not taken.
✗ Branch 1201 not taken.
✗ Branch 1202 not taken.
✗ Branch 1203 not taken.
✗ Branch 1204 not taken.
✗ Branch 1205 not taken.
✗ Branch 1206 not taken.
✗ Branch 1207 not taken.
✗ Branch 1208 not taken.
✗ Branch 1209 not taken.
✗ Branch 1210 not taken.
✗ Branch 1211 not taken.
✗ Branch 1212 not taken.
✗ Branch 1213 not taken.
✗ Branch 1214 not taken.
✗ Branch 1215 not taken.
✗ Branch 1216 not taken.
✗ Branch 1217 not taken.
✗ Branch 1218 not taken.
✗ Branch 1219 not taken.
✗ Branch 1220 not taken.
✗ Branch 1221 not taken.
✗ Branch 1222 not taken.
✗ Branch 1223 not taken.
✗ Branch 1224 not taken.
✗ Branch 1225 not taken.
✗ Branch 1226 not taken.
✗ Branch 1227 not taken.
✗ Branch 1228 not taken.
✗ Branch 1229 not taken.
✗ Branch 1230 not taken.
✗ Branch 1231 not taken.
✗ Branch 1232 not taken.
✗ Branch 1233 not taken.
✗ Branch 1234 not taken.
✗ Branch 1235 not taken.
✗ Branch 1236 not taken.
✗ Branch 1237 not taken.
✗ Branch 1238 not taken.
✗ Branch 1239 not taken.
✗ Branch 1240 not taken.
✗ Branch 1241 not taken.
✗ Branch 1242 not taken.
✗ Branch 1243 not taken.
✗ Branch 1244 not taken.
✗ Branch 1245 not taken.
✗ Branch 1246 not taken.
✗ Branch 1247 not taken.
✗ Branch 1248 not taken.
✗ Branch 1249 not taken.
✗ Branch 1250 not taken.
✗ Branch 1251 not taken.
✗ Branch 1252 not taken.
✗ Branch 1253 not taken.
✗ Branch 1254 not taken.
✗ Branch 1255 not taken.
✗ Branch 1256 not taken.
✗ Branch 1257 not taken.
✗ Branch 1258 not taken.
✗ Branch 1259 not taken.
✗ Branch 1260 not taken.
✗ Branch 1261 not taken.
✗ Branch 1262 not taken.
✗ Branch 1263 not taken.
✗ Branch 1264 not taken.
✗ Branch 1265 not taken.
✗ Branch 1266 not taken.
2767179039 switch(arg)
3499 {
3500
3501 case INCQST:
3502 {
3503 //zprint2("Incrementing Quest\n");
3504 int32_t newqst = 0;
3505 if ( game->get_quest() < 255 ) //255 is a custom quest
3506 {
3507 newqst = (game->get_quest()+1);
3508 }
3509 else
3510 {
3511 newqst = 1;
3512 }
3513 //zprint2("newqst is: %d\n", newqst);
3514 if ( newqst < 11 )
3515 {
3516
3517 ret = newqst * 10000;
3518 Quit = qINCQST;
3519 //ending();
3520
3521 }
3522 else ret = -10000;
3523 break;
3524 }
3525 //Debug->Null()
3526 case DONULL:
3527 ret = 0;
3528 break;
3529 case DEBUGTESTING:
3530 43 ret = use_testingst_start ? 10000 : 0;
3531 43 break;
3532
3533 //debug ri->d[]
3534 case DEBUGD:
3535 {
3536 int32_t a = ri->d[rINDEX] / 10000;
3537 ret = ri->d[a] * 10000;
3538 break;
3539 }
3540
3541 ///----------------------------------------------------------------------------------------------------//
3542 //FFC Variables
3543 case DATA:
3544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4436597 times.
4436597 if(BC::checkFFC(ri->ffcref, "ffc->Data") == SH::_NoError)
3545 4436597 ret = tmpscr->ffcs[ri->ffcref].getData() *10000;
3546 4436597 break;
3547
3548 case FFSCRIPT:
3549
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 468470856 times.
468471068 if(BC::checkFFC(ri->ffcref, "ffc->Script") == SH::_NoError)
3550 468470856 ret = tmpscr->ffcs[ri->ffcref].script*10000;
3551 468471068 break;
3552
3553 case FCSET:
3554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1183551 times.
1183551 if(BC::checkFFC(ri->ffcref, "ffc->CSet") == SH::_NoError)
3555 1183551 ret = tmpscr->ffcs[ri->ffcref].cset*10000;
3556 1183551 break;
3557
3558 case DELAY:
3559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(BC::checkFFC(ri->ffcref, "ffc->Delay") == SH::_NoError)
3560 5 ret = tmpscr->ffcs[ri->ffcref].delay*10000;
3561 5 break;
3562
3563 case FX:
3564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8343964 times.
8343964 if(BC::checkFFC(ri->ffcref, "ffc->X") == SH::_NoError)
3565 8343964 ret = tmpscr->ffcs[ri->ffcref].x.getZLong();
3566 8343964 break;
3567
3568 case FY:
3569
1/2
✓ Branch 0 taken 7892558 times.
✗ Branch 1 not taken.
7892558 if(BC::checkFFC(ri->ffcref, "ffc->Y") == SH::_NoError)
3570 7892558 ret = tmpscr->ffcs[ri->ffcref].y.getZLong();
3571 7892558 break;
3572
3573 case XD:
3574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(BC::checkFFC(ri->ffcref, "ffc->Vx") == SH::_NoError)
3575 35 ret = tmpscr->ffcs[ri->ffcref].vx.getZLong();
3576 35 break;
3577
3578 case YD:
3579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(BC::checkFFC(ri->ffcref, "ffc->Vy") == SH::_NoError)
3580 35 ret = tmpscr->ffcs[ri->ffcref].vy.getZLong();
3581 35 break;
3582 case FFCID:
3583 if(BC::checkFFC(ri->ffcref, "ffc->ID") == SH::_NoError)
3584 ret=(ri->ffcref*10000)+10000;
3585 break;
3586
3587 case XD2:
3588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(BC::checkFFC(ri->ffcref, "ffc->Ax") == SH::_NoError)
3589 35 ret = tmpscr->ffcs[ri->ffcref].ax.getZLong();
3590 35 break;
3591
3592 case YD2:
3593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(BC::checkFFC(ri->ffcref, "ffc->Ay") == SH::_NoError)
3594 35 ret = tmpscr->ffcs[ri->ffcref].ay.getZLong();
3595 35 break;
3596
3597 case FFFLAGSD:
3598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2177905 times.
2177905 if(BC::checkFFC(ri->ffcref, "ffc->Flags[]") == SH::_NoError)
3599 2177905 ret=((tmpscr->ffcs[ri->ffcref].flags >> (ri->d[rINDEX] / 10000))&1) ? 10000 : 0;
3600 2177905 break;
3601
3602 case FFCWIDTH:
3603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if(BC::checkFFC(ri->ffcref, "ffc->EffectWidth") == SH::_NoError)
3604 103 ret=(tmpscr->ffcs[ri->ffcref].hit_width*10000);
3605 103 break;
3606
3607 case FFCHEIGHT:
3608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 if(BC::checkFFC(ri->ffcref, "ffc->EffectHeight") == SH::_NoError)
3609 98 ret=(tmpscr->ffcs[ri->ffcref].hit_height*10000);
3610 98 break;
3611
3612 case FFTWIDTH:
3613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2593791 times.
2593791 if(BC::checkFFC(ri->ffcref, "ffc->TileWidth") == SH::_NoError)
3614 2593791 ret=(tmpscr->ffcs[ri->ffcref].txsz*10000);
3615 2593791 break;
3616
3617 case FFTHEIGHT:
3618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2594062 times.
2594062 if(BC::checkFFC(ri->ffcref, "ffc->TileHeight") == SH::_NoError)
3619 2594062 ret=(tmpscr->ffcs[ri->ffcref].tysz*10000);
3620 2594062 break;
3621
3622 case FFLINK:
3623 if(BC::checkFFC(ri->ffcref, "ffc->Link") == SH::_NoError)
3624 ret=(tmpscr->ffcs[ri->ffcref].link)*10000;
3625 break;
3626
3627 case FFMISCD:
3628 {
3629 6076 int32_t a = ri->d[rINDEX] / 10000;
3630
3631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6076 times.
6076 if(BC::checkMisc(a, "ffc->Misc") != SH::_NoError)
3632 ret = -10000;
3633 else
3634 {
3635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6076 times.
6076 if(BC::checkFFC(ri->ffcref, "ffc->Misc[]") == SH::_NoError)
3636 6076 ret = ffmisc[ri->ffcref][a];
3637 }
3638 }
3639 6076 break;
3640
3641 case FFINITDD:
3642 {
3643 28819 int32_t a = ri->d[rINDEX] / 10000;
3644
3645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28819 times.
28819 if(BC::checkBounds(a, 0, 7, "ffc->InitD") != SH::_NoError)
3646 ret = -10000;
3647 else
3648 {
3649
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 28802 times.
28819 if(BC::checkFFC(ri->ffcref, "ffc->InitD[]") == SH::_NoError)
3650 28802 ret = tmpscr->ffcs[ri->ffcref].initd[a];
3651 }
3652 }
3653 28819 break;
3654
3655 ///----------------------------------------------------------------------------------------------------//
3656 //Hero's Variables
3657 case LINKX:
3658 {
3659
2/2
✓ Branch 0 taken 1455814 times.
✓ Branch 1 taken 13588557 times.
15044371 if (get_qr(qr_SPRITEXY_IS_FLOAT))
3660 {
3661 //double lx = (double)Hero.getX();
3662 //Z_scripterrlog("lx: %f\n", lx);
3663
3664 //ret = lx * 10000;
3665 //zfix lx = Hero.getX();
3666 //Z_scripterrlog("lx: %d\n", lx);
3667 1455814 ret = Hero.getX().getZLong();
3668 1455814 }
3669 13588557 else ret = int32_t(Hero.getX()) * 10000;
3670
3671 15044371 break;
3672 }
3673
3674 case LINKCSET:
3675 {
3676 1282 ret = Hero.cs * 10000;
3677 1282 break;
3678 }
3679 case LINKY:
3680 {
3681
2/2
✓ Branch 0 taken 1420560 times.
✓ Branch 1 taken 13481797 times.
14902357 if (get_qr(qr_SPRITEXY_IS_FLOAT))
3682 {
3683 1420560 ret = Hero.getY().getZLong();
3684 1420560 }
3685 13481797 else ret = int32_t(Hero.getY()) * 10000;
3686
3687 14902357 break;
3688 }
3689 case LINKZ:
3690 {
3691
2/2
✓ Branch 0 taken 95489 times.
✓ Branch 1 taken 468948 times.
564437 if (get_qr(qr_SPRITEXY_IS_FLOAT))
3692 {
3693 95489 ret = Hero.getZ().getZLong();
3694 95489 }
3695 468948 else ret = int32_t(Hero.getZ()) * 10000;
3696
3697 564437 break;
3698 }
3699 case LINKJUMP:
3700 // -fall/100*10000, but doing it that way screwed up the result
3701 641181 ret = Hero.getFall().getZLong() / -100;
3702 641181 break;
3703
3704 case HEROFAKEJUMP:
3705 ret = Hero.getFakeFall().getZLong() / -100;
3706 break;
3707
3708 case LINKDIR:
3709 765420 ret=(int32_t)(Hero.dir)*10000;
3710 765420 break;
3711
3712 case LINKHITDIR:
3713 ret=(int32_t)(Hero.getHitDir())*10000;
3714 break;
3715
3716 case LINKHP:
3717 15443291 ret=(int32_t)(game->get_life())*10000;
3718 15443291 break;
3719
3720 case LINKGRAVITY:
3721 ret = ( (Hero.moveflags & FLAG_OBEYS_GRAV) ? 10000 : 0 );
3722 break;
3723
3724 case HERONOSTEPFORWARD:
3725 ret = ( (FFCore.nostepforward) ? 10000 : 0 );
3726 break;
3727
3728 case LINKMP:
3729 2112268 ret=(int32_t)(game->get_magic())*10000;
3730 2112268 break;
3731
3732 case LINKMAXHP:
3733 655866 ret=(int32_t)(game->get_maxlife())*10000;
3734 655866 break;
3735
3736 case LINKMAXMP:
3737 552028 ret=(int32_t)(game->get_maxmagic())*10000;
3738 552028 break;
3739
3740 case LINKACTION:
3741 {
3742 //Z_scripterrlog("The present FFCore action is: %d\n", FFCore.getHeroAction());
3743 //int32_t act = FFCore.getHeroAction() * 10000;
3744 44796049 ret = FFCore.getHeroAction() * 10000;
3745 //Z_scripterrlog("The present 'action' return value is: %d\n", act);
3746 //ret = act;
3747 //ret=(int32_t)(Hero.getAction())*10000;
3748 44796049 break;
3749 }
3750
3751 case HEROHEALTHBEEP:
3752 {
3753 //Z_scripterrlog("The present FFCore action is: %d\n", FFCore.getHeroAction());
3754 //int32_t act = FFCore.getHeroAction() * 10000;
3755 ret = heart_beep ? ( heart_beep_timer * 10000 ) : 0;
3756 //Z_scripterrlog("The present 'action' return value is: %d\n", act);
3757 //ret = act;
3758 //ret=(int32_t)(Hero.getAction())*10000;
3759 break;
3760 }
3761
3762 case LINKHELD:
3763 17 ret = (int32_t)(Hero.getHeldItem())*10000;
3764 17 break;
3765
3766 case LINKITEMD:
3767 19615159 ret = game->item[vbound(ri->d[rINDEX]/10000, 0, MAXITEMS-1)] ? 10000 : 0;
3768 19615159 break;
3769
3770 case HEROSTEPS:
3771 ret = lsteps[vbound(ri->d[rINDEX]/10000, 0, 7)] * 10000;
3772 break;
3773
3774 case HEROSTEPRATE:
3775 5424 ret = Hero.getStepRate() * 10000;
3776 5424 break;
3777
3778 case LINKEQUIP:
3779 801723 ret = ((Awpn&0xFF)|((Bwpn&0xFF)<<8))*10000;
3780 801723 break;
3781
3782 case LINKINVIS:
3783 557644 ret = (((int32_t)(Hero.getDontDraw())) ? 10000 : 0);
3784 557644 break;
3785
3786 case LINKINVINC:
3787 623338 ret = (int32_t)(Hero.scriptcoldet)*10000;
3788 623338 break;
3789
3790 case LINKENGINEANIMATE:
3791 ret = (int32_t)(Hero.do_animation)*10000;
3792 break;
3793
3794 case LINKLADDERX:
3795 ret=(int32_t)(Hero.getLadderX())*10000;
3796 break;
3797
3798 case LINKLADDERY:
3799 ret=(int32_t)(Hero.getLadderY())*10000;
3800 break;
3801
3802 case LINKSWORDJINX:
3803 280566 ret = (int32_t)(Hero.getSwordClk())*10000;
3804 280566 break;
3805
3806 case LINKITEMJINX:
3807 481556 ret = (int32_t)(Hero.getItemClk())*10000;
3808 481556 break;
3809
3810 case LINKDRUNK:
3811 ret = (int32_t)(Hero.DrunkClock())*10000;
3812 break;
3813
3814 case LINKMISCD:
3815 6213788 ret = (int32_t)(Hero.miscellaneous[vbound(ri->d[rINDEX]/10000,0,31)]); //Was this buffed before? -Z
3816 6213788 break;
3817
3818
3819 case LINKHITBY:
3820 {
3821 2929 int32_t indx = ri->d[rINDEX]/10000;
3822
1/3
✓ Branch 0 taken 2929 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2929 switch(indx)
3823 {
3824 //screen indices of objects
3825 case 0:
3826 case 1:
3827 case 2:
3828 case 3:
3829 case 8:
3830 case 9:
3831 case 10:
3832 case 11:
3833 case 12:
3834 case 16:
3835 {
3836 2929 ret = (int32_t)(Hero.gethitHeroUID(indx))* 10000;
3837 2929 break;
3838 }
3839 //uids of objects
3840 case 4:
3841 case 5:
3842 case 6:
3843 case 7:
3844 case 13:
3845 case 14:
3846 case 15:
3847 {
3848 ret = (int32_t)(Hero.gethitHeroUID(indx)); //do not multiply by 10000! UIDs are not *10000!
3849 break;
3850 }
3851 default: { Z_scripterrlog("Invalid index passed to Player->HitBy[%d]/n", indx); ret = -1; break; }
3852 }
3853 2929 break;
3854 }
3855 case LINKDEFENCE:
3856 ret = (int32_t)(Hero.get_defence(vbound(ri->d[rINDEX]/10000,0,255)))* 10000;
3857 break;
3858
3859
3860 case LINKROTATION:
3861 if ( get_qr(qr_OLDSPRITEDRAWS) )
3862 {
3863 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
3864 "Player->Rotation");
3865 ret = -1; break;
3866 }
3867 ret = (int32_t)(Hero.rotation)*10000;
3868 break;
3869
3870 case LINKSCALE:
3871 {
3872 if ( get_qr(qr_OLDSPRITEDRAWS) )
3873 {
3874 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
3875 "Player->Scale");
3876 ret = -1; break;
3877 }
3878 //al_trace("Player's scale is: %d\n", Hero.scale);
3879 ret = (int32_t)(Hero.scale*100.0);
3880 break;
3881 }
3882
3883
3884 case LINKHXOFS:
3885 206522 ret = (int32_t)(Hero.hxofs)*10000;
3886 206522 break;
3887
3888 case LINKHYOFS:
3889 206522 ret = (int32_t)(Hero.hyofs)*10000;
3890 206522 break;
3891
3892 case LINKXOFS:
3893 ret = (int32_t)(Hero.xofs)*10000;
3894 break;
3895
3896 case LINKYOFS:
3897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2402 times.
2402 ret = (int32_t)(Hero.yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset))*10000;
3898 2402 break;
3899
3900 case HEROSHADOWXOFS:
3901 ret = (int32_t)(Hero.shadowxofs)*10000;
3902 break;
3903
3904 case HEROSHADOWYOFS:
3905 ret = (int32_t)(Hero.shadowyofs)*10000;
3906 break;
3907
3908 case HEROTOTALDYOFFS:
3909 ret = 10000*(((int32_t)(Hero.yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)))
3910 + ((Hero.switch_hooked && Hero.switchhookstyle == swRISE)
3911 ? -(8-(abs(Hero.switchhookclk-32)/4)) : 0));
3912 break;
3913
3914 case LINKZOFS:
3915 ret = (int32_t)(Hero.zofs)*10000;
3916 break;
3917
3918 case LINKHXSZ:
3919 206547 ret = (int32_t)(Hero.hit_width)*10000;
3920 206547 break;
3921
3922 case LINKHYSZ:
3923 206547 ret = (int32_t)(Hero.hit_height)*10000;
3924 206547 break;
3925
3926 case LINKHZSZ:
3927 173466 ret = (int32_t)(Hero.hzsz)*10000;
3928 173466 break;
3929
3930 case LINKTXSZ:
3931 ret = (int32_t)(Hero.txsz)*10000;
3932 break;
3933
3934 case LINKTYSZ:
3935 ret = (int32_t)(Hero.tysz)*10000;
3936 break;
3937
3938 case LINKTILE:
3939 4636 ret = (int32_t)(Hero.tile)*10000;
3940 4636 break;
3941
3942 case LINKFLIP:
3943 ret = (int32_t)(Hero.flip)*10000;
3944 break;
3945
3946 case LINKINVFRAME:
3947 ret = (int32_t)Hero.getHClk()*10000;
3948 break;
3949
3950 case LINKCANFLICKER:
3951 ret= Hero.getCanFlicker()?10000:0;
3952 break;
3953 case LINKHURTSFX:
3954 ret = (int32_t)Hero.getHurtSFX()*10000;
3955 break;
3956
3957 /*
3958 case LINKUSINGITEM:
3959 ret = (int32_t)Hero.getDirectItem()*10000;
3960 break;
3961
3962 case LINKUSINGITEMA:
3963 ret = (int32_t)Hero.getDirectItemA()*10000;
3964 break;
3965
3966 case LINKUSINGITEMB:
3967 ret = (int32_t)Hero.getDirectItemB()*10000;
3968 break;
3969 */
3970
3971 case LINKEATEN:
3972 ret=(int32_t)Hero.getEaten()*10000;
3973 break;
3974 case LINKGRABBED:
3975 ret = Hero.inwallm ? 10000 : 0;
3976 break;
3977 case HEROBUNNY:
3978 ret = Hero.BunnyClock()*10000;
3979 break;
3980 case LINKPUSH:
3981 ret=(int32_t)Hero.getPushing()*10000;
3982 break;
3983 case LINKSTUN:
3984 ret=(int32_t)Hero.StunClock()*10000;
3985 break;
3986 case LINKSCRIPTTILE:
3987 2 ret=script_hero_sprite*10000;
3988 2 break;
3989
3990 case HEROSCRIPTCSET:
3991 ret=script_hero_cset*10000;
3992 break;
3993 case LINKSCRIPFLIP:
3994 ret=script_hero_flip*10000;
3995 break;
3996
3997
3998 case LINKITEMB:
3999 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
4000 19671 ret = Bwpn*10000;
4001 19671 break;
4002
4003 case LINKITEMA:
4004 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
4005 20320 ret = Awpn *10000;
4006 20320 break;
4007
4008 case LINKITEMX:
4009 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
4010 12319 ret = Xwpn *10000;
4011 12319 break;
4012
4013 case LINKITEMY:
4014 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
4015 13864 ret = Ywpn *10000;
4016 13864 break;
4017
4018 case LINKTILEMOD:
4019 ret = Hero.getTileModifier() * 10000;
4020 break;
4021
4022 case LINKDIAG:
4023 ret=Hero.getDiagMove()?10000:0;
4024 break;
4025
4026 case LINKBIGHITBOX:
4027 9024 ret=Hero.getBigHitbox()?10000:0;
4028 9024 break;
4029
4030 case LINKCLIMBING:
4031 ret = Hero.getOnSideviewLadder()?10000:0;
4032 break;
4033
4034 case HEROJUMPCOUNT:
4035 ret = Hero.extra_jump_count * 10000;
4036 break;
4037
4038 case HEROPULLDIR:
4039 ret = Hero.pit_pulldir * 10000;
4040 break;
4041
4042 case HEROPULLCLK:
4043 ret = Hero.pit_pullclk * 10000;
4044 break;
4045
4046 case HEROFALLCLK:
4047 88721 ret = Hero.fallclk * 10000;
4048 88721 break;
4049
4050 case HEROFALLCMB:
4051 ret = Hero.fallCombo * 10000;
4052 break;
4053
4054 case HERODROWNCLK:
4055 ret = Hero.drownclk * 10000;
4056 break;
4057
4058 case HERODROWNCMB:
4059 ret = Hero.drownCombo * 10000;
4060 break;
4061
4062 case HEROFAKEZ:
4063 {
4064 if (get_qr(qr_SPRITEXY_IS_FLOAT))
4065 {
4066 ret = Hero.getFakeZ().getZLong();
4067 }
4068 else ret = int32_t(Hero.getFakeZ()) * 10000;
4069
4070 break;
4071 }
4072 case HEROMOVEFLAGS:
4073 {
4074 int32_t indx = ri->d[rINDEX]/10000;
4075 if(BC::checkBounds(indx, 0, 10, "Hero->MoveFlags[]") != SH::_NoError)
4076 ret = 0; //false
4077 else
4078 {
4079 //All bits, in order, of a single byte; just use bitwise
4080 ret = (Hero.moveflags & (1<<indx)) ? 10000 : 0;
4081 }
4082 break;
4083 }
4084 case HEROLIFTFLAGS:
4085 {
4086 int32_t indx = ri->d[rINDEX]/10000;
4087 if(BC::checkBounds(indx, 0, NUM_LIFTFL-1, "Hero->LiftFlags[]") != SH::_NoError)
4088 ret = 0; //false
4089 else
4090 {
4091 ret = (Hero.liftflags & (1<<indx)) ? 10000 : 0;
4092 }
4093 break;
4094 }
4095
4096 case HEROSHIELDJINX:
4097 ret = Hero.shieldjinxclk * 10000;
4098 break;
4099
4100 case HEROISWARPING:
4101 561 ret = Hero.is_warping ? 10000L : 0L;
4102 561 break;
4103
4104 case CLOCKACTIVE:
4105 ret=watch?10000:0;
4106 break;
4107
4108 case CLOCKCLK:
4109 ret=clockclk*10000;
4110 break;
4111
4112 case HERORESPAWNX:
4113 {
4114 ret = Hero.respawn_x.getZLong();
4115 break;
4116 }
4117
4118 case HERORESPAWNY:
4119 {
4120 ret = Hero.respawn_y.getZLong();
4121 break;
4122 }
4123
4124 case HERORESPAWNDMAP:
4125 {
4126 ret = Hero.respawn_dmap * 10000;
4127 break;
4128 }
4129
4130 case HERORESPAWNSCR:
4131 {
4132 ret = Hero.respawn_scr * 10000;
4133 break;
4134 }
4135
4136 case HEROSWITCHTIMER:
4137 {
4138 ret = Hero.switchhookclk * 10000;
4139 break;
4140 }
4141
4142 case HEROSWITCHMAXTIMER:
4143 {
4144 ret = Hero.switchhookmaxtime * 10000;
4145 break;
4146 }
4147
4148 case HEROIMMORTAL:
4149 {
4150 ret = Hero.immortal * 10000;
4151 break;
4152 }
4153
4154 case HEROSTANDING:
4155 {
4156 ret = Hero.isStanding(true) ? 10000 : 0;
4157 break;
4158 }
4159
4160 case HEROCOYOTETIME:
4161 {
4162 ret = Hero.coyotetime*10000;
4163 break;
4164 }
4165
4166 case HEROLIFTEDWPN:
4167 {
4168 ret = Hero.lift_wpn ? Hero.lift_wpn->getUID() : 0;
4169 break;
4170 }
4171 case HEROLIFTTIMER:
4172 {
4173 ret = Hero.liftclk * 10000;
4174 break;
4175 }
4176 case HEROLIFTMAXTIMER:
4177 {
4178 ret = Hero.tliftclk * 10000;
4179 break;
4180 }
4181 case HEROLIFTHEIGHT:
4182 {
4183 ret = Hero.liftheight.getZLong();
4184 break;
4185 }
4186 case HEROHAMMERSTATE:
4187 {
4188 ret = Hero.getHammerState() * 10000;
4189 break;
4190 }
4191
4192 ///----------------------------------------------------------------------------------------------------//
4193 //Input States
4194 case INPUTSTART:
4195 92884 ret=control_state[6]?10000:0;
4196 92884 break;
4197
4198 case INPUTMAP:
4199 4123 ret=control_state[9]?10000:0;
4200 4123 break;
4201
4202 case INPUTUP:
4203 1334804 ret=control_state[0]?10000:0;
4204 1334804 break;
4205
4206 case INPUTDOWN:
4207 847912 ret=control_state[1]?10000:0;
4208 847912 break;
4209
4210 case INPUTLEFT:
4211 1328070 ret=control_state[2]?10000:0;
4212 1328070 break;
4213
4214 case INPUTRIGHT:
4215 1370269 ret=control_state[3]?10000:0;
4216 1370269 break;
4217
4218 case INPUTA:
4219 5693944 ret=control_state[4]?10000:0;
4220 5693944 break;
4221
4222 case INPUTB:
4223 5182994 ret=control_state[5]?10000:0;
4224 5182994 break;
4225
4226 case INPUTL:
4227 3135646 ret=control_state[7]?10000:0;
4228 3135646 break;
4229
4230 case INPUTR:
4231 3131387 ret=control_state[8]?10000:0;
4232 3131387 break;
4233
4234 case INPUTEX1:
4235 119289 ret=control_state[10]?10000:0;
4236 119289 break;
4237
4238 case INPUTEX2:
4239 119580 ret=control_state[11]?10000:0;
4240 119580 break;
4241
4242 case INPUTEX3:
4243 23391 ret=control_state[12]?10000:0;
4244 23391 break;
4245
4246 case INPUTEX4:
4247 23391 ret=control_state[13]?10000:0;
4248 23391 break;
4249
4250 case INPUTAXISUP:
4251 ret=control_state[14]?10000:0;
4252 break;
4253
4254 case INPUTAXISDOWN:
4255 ret=control_state[15]?10000:0;
4256 break;
4257
4258 case INPUTAXISLEFT:
4259 ret=control_state[16]?10000:0;
4260 break;
4261
4262 case INPUTAXISRIGHT:
4263 ret=control_state[17]?10000:0;
4264 break;
4265
4266 case INPUTMOUSEX:
4267 {
4268 766680 ret=get_mouse_state(0)*10000;
4269 766680 break;
4270 }
4271
4272 case INPUTMOUSEY:
4273 {
4274 766680 int32_t mousequakeoffset = 56+((int32_t)(zc::math::Sin((double)(quakeclk*int64_t(2)-frame))*4));
4275
3/4
✓ Branch 0 taken 17451 times.
✓ Branch 1 taken 749229 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 749229 times.
766680 int32_t tempoffset = (quakeclk > 0) ? mousequakeoffset : (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
4276 766680 ret=((get_mouse_state(1)-tempoffset))*10000;
4277 766680 break;
4278 }
4279
4280 case INPUTMOUSEZ:
4281 ret=(get_mouse_state(2))*10000;
4282 break;
4283
4284 case INPUTMOUSEB:
4285 1041016 ret=(get_mouse_state(3))*10000;
4286 1041016 break;
4287
4288 case INPUTPRESSSTART:
4289 728101 ret=button_press[6]?10000:0;
4290 728101 break;
4291
4292 case INPUTPRESSMAP:
4293 276546 ret=button_press[9]?10000:0;
4294 276546 break;
4295
4296 case INPUTPRESSUP:
4297 776094 ret=button_press[0]?10000:0;
4298 776094 break;
4299
4300 case INPUTPRESSDOWN:
4301 715737 ret=button_press[1]?10000:0;
4302 715737 break;
4303
4304 case INPUTPRESSLEFT:
4305 557304 ret=button_press[2]?10000:0;
4306 557304 break;
4307
4308 case INPUTPRESSRIGHT:
4309 514964 ret=button_press[3]?10000:0;
4310 514964 break;
4311
4312 case INPUTPRESSA:
4313 1875584 ret=button_press[4]?10000:0;
4314 1875584 break;
4315
4316 case INPUTPRESSB:
4317 1726419 ret=button_press[5]?10000:0;
4318 1726419 break;
4319
4320 case INPUTPRESSL:
4321 1861217 ret=button_press[7]?10000:0;
4322 1861217 break;
4323
4324 case INPUTPRESSR:
4325 1691656 ret=button_press[8]?10000:0;
4326 1691656 break;
4327
4328 case INPUTPRESSEX1:
4329 873882 ret=button_press[10]?10000:0;
4330 873882 break;
4331
4332 case INPUTPRESSEX2:
4333 873847 ret=button_press[11]?10000:0;
4334 873847 break;
4335
4336 case INPUTPRESSEX3:
4337 541201 ret=button_press[12]?10000:0;
4338 541201 break;
4339
4340 case INPUTPRESSEX4:
4341 541201 ret=button_press[13]?10000:0;
4342 541201 break;
4343
4344 case INPUTPRESSAXISUP:
4345 ret=button_press[14]?10000:0;
4346 break;
4347
4348 case INPUTPRESSAXISDOWN:
4349 ret=button_press[15]?10000:0;
4350 break;
4351
4352 case INPUTPRESSAXISLEFT:
4353 ret=button_press[16]?10000:0;
4354 break;
4355
4356 case INPUTPRESSAXISRIGHT:
4357 ret=button_press[17]?10000:0;
4358 break;
4359
4360 case FFRULE:
4361 {
4362 14 int32_t ruleid = vbound((ri->d[rINDEX]/10000),0,qr_MAX);
4363 14 ret = get_qr(ruleid)?10000:0;
4364 }
4365 14 break;
4366
4367 case BUTTONPRESS:
4368 // DUkey, DDkey, DLkey, DRkey, Akey, Bkey, Skey, Lkey, Rkey, Pkey, Exkey1, Exkey2, Exkey3, Exkey4 };
4369 {
4370 //Read-only
4371 3743 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
4372 3743 ret = button_press[button]?10000:0;
4373 }
4374 3743 break;
4375
4376 case BUTTONINPUT:
4377 {
4378 //Read-only
4379 213 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
4380 213 ret=control_state[button]?10000:0;
4381 }
4382 213 break;
4383
4384 case BUTTONHELD:
4385 {
4386 //Read-only
4387 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
4388 ret = button_hold[button]?10000:0;
4389 }
4390 break;
4391
4392 case RAWKEY:
4393 { //Game->KeyPressed[], read-only
4394 //if ( !keypressed() ) break; //Don;t return values set by setting Hero->Input/Press
4395 //hmm...no, this won;t return properly for modifier keys.
4396 int32_t keyid = ri->d[rINDEX]/10000;
4397 //key = vbound(key,0,n);
4398 bool pressed = key_current_frame[keyid] != 0;
4399 ret = pressed?10000:0;
4400 }
4401 break;
4402
4403 case KEYINPUT:
4404 {
4405 1121 ret = KeyInput[ri->d[rINDEX]/10000] ? 10000 : 0;
4406 1121 break;
4407 }
4408 case KEYPRESS:
4409 {
4410 6774 ret = KeyPress[ri->d[rINDEX]/10000] ? 10000 : 0;
4411 6774 break;
4412 }
4413
4414 case KEYMODIFIERS:
4415 {
4416 ret = (key_shifts*10000);
4417 break;
4418 }
4419
4420 case KEYBINDINGS:
4421 {
4422 int32_t keyid = ri->d[rINDEX]/10000;
4423 switch(keyid)
4424 {
4425 case 0: ret = DUkey * 10000; break;
4426 case 1: ret = DDkey * 10000; break;
4427 case 2: ret = DLkey * 10000; break;
4428 case 3: ret = DRkey * 10000; break;
4429 case 4: ret = Akey * 10000; break;
4430 case 5: ret = Bkey * 10000; break;
4431 case 6: ret = Skey * 10000; break;
4432 case 7: ret = Lkey * 10000; break;
4433 case 8: ret = Rkey * 10000; break;
4434 case 9: ret = Pkey * 10000; /*map*/ break;
4435 case 10: ret = Exkey1 * 10000; break;
4436 case 11: ret = Exkey2 * 10000; break;
4437 case 12: ret = Exkey3 * 10000; break;
4438 case 13: ret = Exkey4 * 10000; break;
4439
4440 default: { Z_scripterrlog("Invalid index [%d] passed to Input->KeyBindings[]\n", keyid); ret = 0; break; }
4441 }
4442 break;
4443 }
4444
4445 case READKEY:
4446 {
4447 //Game->ReadKey(int32_t key), also clears it.
4448 int32_t keyid = ri->d[rINDEX]/10000;
4449 bool pressed = zc_readkey(keyid, true);
4450 ret = pressed?10000:0;
4451 }
4452 break;
4453
4454 case DISABLEKEY:
4455 {
4456 //Input->DisableKey(int32_t key)
4457 int32_t keyid = ri->d[rINDEX]/10000;
4458 ret = disabledKeys[keyid]?10000:0;
4459 break;
4460 }
4461
4462 case DISABLEBUTTON:
4463 {
4464 //Input->DisableButton(int32_t cb)
4465 int32_t cbid = ri->d[rINDEX]/10000;
4466 ret = disable_control[cbid]?10000:0;
4467 break;
4468 }
4469
4470 case JOYPADPRESS:
4471 {
4472 //Checks if a press is from the joypad, not keyboard.
4473 int32_t button = ri->d[rINDEX]/10000;
4474 ret = joybtn(button)?10000:0;
4475 }
4476 break;
4477
4478
4479 case MOUSEARR:
4480 {
4481 468 int32_t indx = (ri->d[rINDEX]/10000);
4482 int32_t rv;
4483
2/7
✗ Branch 0 not taken.
✓ Branch 1 taken 234 times.
✓ Branch 2 taken 234 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
468 switch (indx)
4484 {
4485 case 0: //MouseX
4486 {
4487 234 rv=get_mouse_state(0)*10000;
4488 234 break;
4489 }
4490 case 1: //MouseY
4491 {
4492 234 int32_t mousequakeoffset = 56+((int32_t)(zc::math::Sin((double)(quakeclk*int64_t(2)-frame))*4));
4493
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 234 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 234 times.
234 int32_t tempoffset = (quakeclk > 0) ? mousequakeoffset : (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
4494 234 int32_t topOffset= (112-tempoffset);
4495 234 rv=(get_mouse_state(1)-topOffset)*10000;
4496 234 break;
4497 }
4498 case 2: //MouseZ
4499 {
4500 rv=(get_mouse_state(2))*10000;
4501 break;
4502 }
4503 case 3: //Left Click
4504 {
4505 rv=((get_mouse_state(3)&0x1))*10000;
4506 break;
4507 }
4508 case 4: //Right Click
4509 {
4510 rv=((get_mouse_state(3)&0x2))*10000;
4511 break;
4512 }
4513 case 5: //Middle Click
4514 {
4515 rv=((get_mouse_state(3)&0x4))*10000;
4516 break;
4517 }
4518 default:
4519 {
4520 Z_scripterrlog("Invalid index passed to Input->Mouse[]: %d\n", indx);
4521 rv = -10000;
4522 break;
4523 }
4524 }
4525
4526 //bool pressed = key[keyid] != 0;
4527 //ret = pressed?10000:0;
4528 468 ret = rv;
4529 }
4530 468 break;
4531
4532 ///----------------------------------------------------------------------------------------------------//
4533 //Item Variables
4534 case ITEMSCALE:
4535 if ( get_qr(qr_OLDSPRITEDRAWS) )
4536 {
4537 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
4538 "item->Scale");
4539 ret = -1; break;
4540 }
4541 if(0!=(s=checkItem(ri->itemref)))
4542 {
4543 ret=((int32_t)((item*)(s))->scale)*100.0;
4544 }
4545 break;
4546
4547 case ITEMX:
4548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5848 times.
5848 if(0!=(s=checkItem(ri->itemref)))
4549 {
4550
2/2
✓ Branch 0 taken 2722 times.
✓ Branch 1 taken 3126 times.
5848 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
4551 {
4552 2722 ret=(((item*)(s))->x).getZLong();
4553 2722 }
4554 3126 else ret=((int32_t)((item*)(s))->x)*10000;
4555 5848 }
4556 5848 break;
4557
4558 case ITEMSPRITESCRIPT:
4559 if(0!=(s=checkItem(ri->itemref)))
4560 {
4561 ret=((int32_t)((item*)(s))->script)*10000;
4562 }
4563 break;
4564
4565 case ITEMSPRITEINITD:
4566
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(0!=(s=checkItem(ri->itemref)))
4567 {
4568 24 int32_t a = vbound(ri->d[rINDEX]/10000,0,7);
4569 24 ret=((int32_t)((item*)(s))->initD[a]);
4570 24 }
4571 24 break;
4572
4573 case ITEMFAMILY:
4574 if(0!=(s=checkItem(ri->itemref)))
4575 {
4576 ret=((int32_t)((item*)(s))->family)*10000;
4577 }
4578 break;
4579
4580 case ITEMLEVEL:
4581 if(0!=(s=checkItem(ri->itemref)))
4582 {
4583 ret=((int32_t)((item*)(s))->lvl)*10000;
4584 }
4585 break;
4586
4587 case SPRITEMAXITEM:
4588 {
4589 //No bounds check, as this is a universal function and works from NULL pointers!
4590 ret = items.getMax() * 10000;
4591 break;
4592 }
4593
4594 case ITEMSCRIPTUID:
4595 if(0!=(s=checkItem(ri->itemref)))
4596 {
4597 ret=((int32_t)((item*)(s))->script_UID); //Literal, not *10000
4598 }
4599 break;
4600
4601 case ITEMY:
4602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4206 times.
4206 if(0!=(s=checkItem(ri->itemref)))
4603 {
4604
2/2
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 3126 times.
4206 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
4605 {
4606 1080 ret=(((item*)(s))->y).getZLong();
4607 1080 }
4608 else
4609 3126 ret=((int32_t)((item*)(s))->y)*10000;
4610 4206 }
4611 4206 break;
4612
4613 case ITEMZ:
4614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5084 times.
5084 if(0!=(s=checkItem(ri->itemref)))
4615 {
4616
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5082 times.
5084 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
4617 {
4618 2 ret=(((item*)(s))->z).getZLong();
4619 2 }
4620 else
4621 5082 ret=((int32_t)((item*)(s))->z)*10000;
4622 5084 }
4623 5084 break;
4624
4625 case ITEMJUMP:
4626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(0!=(s=checkItem(ri->itemref)))
4627 {
4628 114 ret = ((item*)(s))->fall.getZLong() / -100;
4629
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
4630 114 }
4631 114 break;
4632
4633 case ITEMFAKEJUMP:
4634 if(0!=(s=checkItem(ri->itemref)))
4635 {
4636 ret = ((item*)(s))->fakefall.getZLong() / -100;
4637 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
4638 }
4639 break;
4640
4641 case ITEMDRAWTYPE:
4642 if(0!=(s=checkItem(ri->itemref)))
4643 {
4644 ret=((item*)(s))->drawstyle*10000;
4645 }
4646 break;
4647
4648 case ITEMGRAVITY:
4649 if(0!=(s=checkItem(ri->itemref)))
4650 {
4651 ret=((((item*)(s))->moveflags & FLAG_OBEYS_GRAV) ? 10000 : 0);
4652 }
4653 break;
4654
4655 case ITEMID:
4656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117090 times.
117090 if(0!=(s=checkItem(ri->itemref)))
4657 {
4658 117090 ret=((item*)(s))->id*10000;
4659 117090 }
4660 117090 break;
4661
4662 case ITEMTILE:
4663
1/2
✓ Branch 0 taken 7933 times.
✗ Branch 1 not taken.
7933 if(0!=(s=checkItem(ri->itemref)))
4664 {
4665 7933 ret=((item*)(s))->tile*10000;
4666 7933 }
4667 7933 break;
4668
4669 case ITEMSCRIPTTILE:
4670 if(0!=(s=checkItem(ri->itemref)))
4671 {
4672 ret=((item*)(s))->scripttile*10000;
4673 }
4674 break;
4675
4676 case ITEMSCRIPTFLIP:
4677 if(0!=(s=checkItem(ri->itemref)))
4678 {
4679 ret=((item*)(s))->scriptflip*10000;
4680 }
4681 break;
4682
4683 case ITEMPSTRING:
4684 if(0!=(s=checkItem(ri->itemref)))
4685 {
4686 ret=((item*)(s))->pstring*10000;
4687 }
4688 break;
4689 case ITEMPSTRINGFLAGS:
4690 if(0!=(s=checkItem(ri->itemref)))
4691 {
4692 ret=((item*)(s))->pickup_string_flags*10000;
4693 }
4694 break;
4695 case ITEMOVERRIDEFLAGS:
4696 ret=0;
4697 break;
4698
4699 case ITEMOTILE:
4700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(0!=(s=checkItem(ri->itemref)))
4701 {
4702 18 ret=((item*)(s))->o_tile*10000;
4703 18 }
4704 18 break;
4705
4706 case ITEMCSET:
4707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7933 times.
7933 if(0!=(s=checkItem(ri->itemref)))
4708 {
4709 7933 ret=(((item*)(s))->o_cset&15)*10000;
4710 7933 }
4711 7933 break;
4712
4713 case ITEMFLASHCSET:
4714 if(0!=(s=checkItem(ri->itemref)))
4715 {
4716 ret=(((item*)(s))->o_cset>>4)*10000;
4717 }
4718 break;
4719
4720 case ITEMFRAMES:
4721 if(0!=(s=checkItem(ri->itemref)))
4722 {
4723 ret=((item*)(s))->frames*10000;
4724 }
4725 break;
4726
4727 case ITEMFRAME:
4728 if(0!=(s=checkItem(ri->itemref)))
4729 {
4730 ret=((item*)(s))->aframe*10000;
4731 }
4732 break;
4733
4734 case ITEMACLK:
4735 if(0!=(s=checkItem(ri->itemref)))
4736 {
4737 ret=((item*)(s))->aclk*10000;
4738 }
4739 break;
4740
4741 case ITEMASPEED:
4742 if(0!=(s=checkItem(ri->itemref)))
4743 {
4744 ret=((item*)(s))->o_speed*10000;
4745 }
4746 break;
4747
4748 case ITEMDELAY:
4749 if(0!=(s=checkItem(ri->itemref)))
4750 {
4751 ret=((item*)(s))->o_delay*10000;
4752 }
4753 break;
4754
4755 case ITEMFLIP:
4756 if(0!=(s=checkItem(ri->itemref)))
4757 {
4758 ret=((item*)(s))->flip*10000;
4759 }
4760 break;
4761
4762 case ITEMFLASH:
4763 if(0!=(s=checkItem(ri->itemref)))
4764 {
4765 ret=((item*)(s))->flash*10000;
4766 }
4767 break;
4768
4769 case ITEMHXOFS:
4770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2552 times.
2552 if(0!=(s=checkItem(ri->itemref)))
4771 {
4772 2552 ret=(((item*)(s))->hxofs)*10000;
4773 2552 }
4774 2552 break;
4775
4776 case ITEMROTATION:
4777 if ( get_qr(qr_OLDSPRITEDRAWS) )
4778 {
4779 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
4780 "item->Rotation");
4781 ret = -1; break;
4782 }
4783 if(0!=(s=checkItem(ri->itemref)))
4784 {
4785 ret=(((item*)(s))->rotation)*10000;
4786 }
4787 break;
4788
4789 case ITEMHYOFS:
4790
1/2
✓ Branch 0 taken 2552 times.
✗ Branch 1 not taken.
2552 if(0!=(s=checkItem(ri->itemref)))
4791 {
4792 2552 ret=(((item*)(s))->hyofs)*10000;
4793 2552 }
4794 2552 break;
4795
4796 case ITEMXOFS:
4797
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(0!=(s=checkItem(ri->itemref)))
4798 {
4799 6 ret=((int32_t)(((item*)(s))->xofs))*10000;
4800 6 }
4801 6 break;
4802
4803 case ITEMYOFS:
4804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 if(0!=(s=checkItem(ri->itemref)))
4805 {
4806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 ret=((int32_t)(((item*)(s))->yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)))*10000;
4807 334 }
4808 334 break;
4809
4810 case ITEMSHADOWXOFS:
4811 if(0!=(s=checkItem(ri->itemref)))
4812 {
4813 ret=((int32_t)(((item*)(s))->shadowyofs))*10000;
4814 }
4815 break;
4816
4817 case ITEMSHADOWYOFS:
4818 if(0!=(s=checkItem(ri->itemref)))
4819 {
4820 ret=((int32_t)(((item*)(s))->shadowxofs))*10000;
4821 }
4822 break;
4823
4824
4825 case ITEMZOFS:
4826 if(0!=(s=checkItem(ri->itemref)))
4827 {
4828 ret=((int32_t)(((item*)(s))->zofs))*10000;
4829 }
4830 break;
4831
4832 case ITEMHXSZ:
4833
1/2
✓ Branch 0 taken 2552 times.
✗ Branch 1 not taken.
2552 if(0!=(s=checkItem(ri->itemref)))
4834 {
4835 2552 ret=(((item*)(s))->hit_width)*10000;
4836 2552 }
4837 2552 break;
4838
4839 case ITEMHYSZ:
4840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2552 times.
2552 if(0!=(s=checkItem(ri->itemref)))
4841 {
4842 2552 ret=(((item*)(s))->hit_height)*10000;
4843 2552 }
4844 2552 break;
4845
4846 case ITEMHZSZ:
4847
1/2
✓ Branch 0 taken 2542 times.
✗ Branch 1 not taken.
2542 if(0!=(s=checkItem(ri->itemref)))
4848 {
4849 2542 ret=(((item*)(s))->hzsz)*10000;
4850 2542 }
4851 2542 break;
4852
4853 case ITEMTXSZ:
4854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1300 times.
1300 if(0!=(s=checkItem(ri->itemref)))
4855 {
4856 1300 ret=(((item*)(s))->txsz)*10000;
4857 1300 }
4858 1300 break;
4859
4860 case ITEMTYSZ:
4861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1300 times.
1300 if(0!=(s=checkItem(ri->itemref)))
4862 {
4863 1300 ret=(((item*)(s))->tysz)*10000;
4864 1300 }
4865 1300 break;
4866
4867 case ITEMCOUNT:
4868 685905 ret=(items.Count())*10000;
4869 685905 break;
4870
4871 case GETRENDERTARGET:
4872 ret=(zscriptDrawingRenderTarget->GetCurrentRenderTarget())*10000;
4873 break;
4874
4875 case ITEMEXTEND:
4876 if(0!=(s=checkItem(ri->itemref)))
4877 {
4878 ret=((item*)(s))->extend*10000;
4879 }
4880 break;
4881
4882 case ITEMPICKUP:
4883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19906 times.
19906 if(0!=(s=checkItem(ri->itemref)))
4884 {
4885 19906 ret=((item*)(s))->pickup*10000;
4886 19906 }
4887 19906 break;
4888
4889 case ITEMMISCD:
4890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108294 times.
108294 if(0!=(s=checkItem(ri->itemref)))
4891 {
4892 108294 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
4893 108294 ret=(((item*)(s))->miscellaneous[a]);
4894 108294 }
4895 108294 break;
4896
4897 case ITEMFALLCLK:
4898 if(0!=(s=checkItem(ri->itemref)))
4899 {
4900 ret = ((item*)(s))->fallclk * 10000;
4901 }
4902 break;
4903
4904 case ITEMFALLCMB:
4905 if(0!=(s=checkItem(ri->itemref)))
4906 {
4907 ret = ((item*)(s))->fallCombo * 10000;
4908 }
4909 break;
4910
4911 case ITEMDROWNCLK:
4912 if(0!=(s=checkItem(ri->itemref)))
4913 {
4914 ret = ((item*)(s))->drownclk * 10000;
4915 }
4916 break;
4917
4918 case ITEMDROWNCMB:
4919 if(0!=(s=checkItem(ri->itemref)))
4920 {
4921 ret = ((item*)(s))->drownCombo * 10000;
4922 }
4923 break;
4924
4925 case ITEMFAKEZ:
4926 if(0!=(s=checkItem(ri->itemref)))
4927 {
4928 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
4929 {
4930 ret=(((item*)(s))->fakez).getZLong();
4931 }
4932 else
4933 ret=((int32_t)((item*)(s))->fakez)*10000;
4934 }
4935 break;
4936
4937
4938 case ITEMMOVEFLAGS:
4939 {
4940 if(0!=(s=checkItem(ri->itemref)))
4941 {
4942 int32_t indx = ri->d[rINDEX]/10000;
4943 if(BC::checkBounds(indx, 0, 10, "itemsprite->MoveFlags[]") != SH::_NoError)
4944 ret = 0; //false
4945 else
4946 {
4947 //All bits, in order, of a single byte; just use bitwise
4948 ret = (((item*)(s))->moveflags & (1<<indx)) ? 10000 : 0;
4949 }
4950 }
4951 break;
4952 }
4953
4954 case ITEMGLOWRAD:
4955 if(0!=(s=checkItem(ri->itemref)))
4956 {
4957 ret = ((item*)(s))->glowRad * 10000;
4958 }
4959 break;
4960
4961 case ITEMGLOWSHP:
4962 if(0!=(s=checkItem(ri->itemref)))
4963 {
4964 ret = ((item*)(s))->glowShape * 10000;
4965 }
4966 break;
4967
4968 case ITEMDIR:
4969 if(0!=(s=checkItem(ri->itemref)))
4970 {
4971 ret = ((item*)(s))->dir * 10000;
4972 }
4973 break;
4974
4975 case ITEMENGINEANIMATE:
4976 if(0!=(s=checkItem(ri->itemref)))
4977 {
4978 ret = int32_t(((item*)(s))->do_animation) * 10000;
4979 }
4980 break;
4981
4982 case ITEMSHADOWSPR:
4983 if(0!=(s=checkItem(ri->itemref)))
4984 {
4985 ret = int32_t(((item*)(s))->spr_shadow) * 10000;
4986 }
4987 break;
4988 case ITEMDROPPEDBY:
4989 if(0!=(s=checkItem(ri->itemref)))
4990 {
4991 ret = int32_t(((item*)(s))->from_dropset) * 10000;
4992 }
4993 break;
4994 case ITMSWHOOKED:
4995 if(0!=(s=checkItem(ri->itemref)))
4996 {
4997 ret = s->switch_hooked ? 10000 : 0;
4998 }
4999 break;
5000 case ITEMFORCEGRAB:
5001 if(0!=(s=checkItem(ri->itemref)))
5002 {
5003 ret = ((item*)s)->get_forcegrab() ? 10000 : 0;
5004 }
5005 break;
5006
5007 ///----------------------------------------------------------------------------------------------------//
5008 //Itemdata Variables
5009
5010
5011 case IDATAUSEWPN:
5012 if(unsigned(ri->idata) >= MAXITEMS)
5013 {
5014 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5015 ret = -10000;
5016 break;
5017 }
5018 ret=(itemsbuf[ri->idata].useweapon)*10000;
5019 break;
5020 case IDATAUSEDEF:
5021 if(unsigned(ri->idata) >= MAXITEMS)
5022 {
5023 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5024 ret = -10000;
5025 break;
5026 }
5027 ret=(itemsbuf[ri->idata].usedefence)*10000;
5028 break;
5029 case IDATAWRANGE:
5030 if(unsigned(ri->idata) >= MAXITEMS)
5031 {
5032 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5033 ret = -10000;
5034 break;
5035 }
5036 ret=(itemsbuf[ri->idata].weaprange)*10000;
5037 break;
5038 case IDATAMAGICTIMER:
5039 if(unsigned(ri->idata) >= MAXITEMS)
5040 {
5041 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5042 ret = -10000;
5043 break;
5044 }
5045 ret=(itemsbuf[ri->idata].magiccosttimer[0])*10000;
5046 break;
5047 case IDATAMAGICTIMER2:
5048 if(unsigned(ri->idata) >= MAXITEMS)
5049 {
5050 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5051 ret = -10000;
5052 break;
5053 }
5054 ret=(itemsbuf[ri->idata].magiccosttimer[1])*10000;
5055 break;
5056 case IDATAUSEMVT:
5057 {
5058 if(unsigned(ri->idata) >= MAXITEMS)
5059 {
5060 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5061 ret = -10000;
5062 break;
5063 }
5064 int32_t a = vbound((ri->d[rINDEX] / 10000),0,(ITEM_MOVEMENT_PATTERNS-1));
5065 ret=(itemsbuf[ri->idata].weap_pattern[a])*10000;
5066 }
5067 break;
5068
5069 case IDATADURATION:
5070 if(unsigned(ri->idata) >= MAXITEMS)
5071 {
5072 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5073 ret = -10000;
5074 break;
5075 }
5076 ret=(itemsbuf[ri->idata].weapduration)*10000;
5077 break;
5078
5079 case IDATADUPLICATES:
5080 if(unsigned(ri->idata) >= MAXITEMS)
5081 {
5082 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5083 ret = -10000;
5084 break;
5085 }
5086 ret=(itemsbuf[ri->idata].duplicates)*10000;
5087 break;
5088 case IDATADRAWLAYER:
5089 if(unsigned(ri->idata) >= MAXITEMS)
5090 {
5091 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5092 ret = -10000;
5093 break;
5094 }
5095 ret=(itemsbuf[ri->idata].drawlayer)*10000;
5096 break;
5097 case IDATACOLLECTFLAGS:
5098 if(unsigned(ri->idata) >= MAXITEMS)
5099 {
5100 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5101 ret = 0;
5102 break;
5103 }
5104 ret=(itemsbuf[ri->idata].collectflags)*10000;
5105 break;
5106 case IDATAWEAPONSCRIPT:
5107 if(unsigned(ri->idata) >= MAXITEMS)
5108 {
5109 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5110 ret = -10000;
5111 break;
5112 }
5113 ret=(itemsbuf[ri->idata].weaponscript)*10000;
5114 break;
5115 case IDATAMISCD:
5116 {
5117 if(unsigned(ri->idata) >= MAXITEMS)
5118 {
5119 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5120 ret = -10000;
5121 break;
5122 }
5123 int32_t a = vbound((ri->d[rINDEX] / 10000),0,31);
5124 ret=(itemsbuf[ri->idata].wpn_misc_d[a])*10000;
5125 }
5126 break;
5127 case IDATAWPNINITD:
5128 {
5129 if(unsigned(ri->idata) >= MAXITEMS)
5130 {
5131 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5132 ret = -10000;
5133 break;
5134 }
5135 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
5136 ret=(itemsbuf[ri->idata].weap_initiald[a]);
5137 }
5138 break;
5139 case IDATAWEAPHXOFS:
5140 if(unsigned(ri->idata) >= MAXITEMS)
5141 {
5142 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5143 ret = -10000;
5144 break;
5145 }
5146 ret=(itemsbuf[ri->idata].weap_hxofs)*10000;
5147 break;
5148 case IDATAWEAPHYOFS:
5149 if(unsigned(ri->idata) >= MAXITEMS)
5150 {
5151 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5152 ret = -10000;
5153 break;
5154 }
5155 ret=(itemsbuf[ri->idata].weap_hyofs)*10000;
5156 break;
5157 case IDATAWEAPHXSZ:
5158 if(unsigned(ri->idata) >= MAXITEMS)
5159 {
5160 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5161 ret = -10000;
5162 break;
5163 }
5164 ret=(itemsbuf[ri->idata].weap_hxsz)*10000;
5165 break;
5166 case IDATAWEAPHYSZ:
5167 if(unsigned(ri->idata) >= MAXITEMS)
5168 {
5169 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5170 ret = -10000;
5171 break;
5172 }
5173 ret=(itemsbuf[ri->idata].weap_hysz)*10000;
5174 break;
5175 case IDATAWEAPHZSZ:
5176 if(unsigned(ri->idata) >= MAXITEMS)
5177 {
5178 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5179 ret = -10000;
5180 break;
5181 }
5182 ret=(itemsbuf[ri->idata].weap_hzsz)*10000;
5183 break;
5184 case IDATAWEAPXOFS:
5185 if(unsigned(ri->idata) >= MAXITEMS)
5186 {
5187 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5188 ret = -10000;
5189 break;
5190 }
5191 ret=(itemsbuf[ri->idata].weap_xofs)*10000;
5192 break;
5193 case IDATAWEAPYOFS:
5194 if(unsigned(ri->idata) >= MAXITEMS)
5195 {
5196 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5197 ret = -10000;
5198 break;
5199 }
5200 ret=(itemsbuf[ri->idata].weap_yofs)*10000;
5201 break;
5202 case IDATAHXOFS:
5203 if(unsigned(ri->idata) >= MAXITEMS)
5204 {
5205 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5206 ret = -10000;
5207 break;
5208 }
5209 ret=(itemsbuf[ri->idata].hxofs)*10000;
5210 break;
5211 case IDATAHYOFS:
5212 if(unsigned(ri->idata) >= MAXITEMS)
5213 {
5214 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5215 ret = -10000;
5216 break;
5217 }
5218 ret=(itemsbuf[ri->idata].hyofs)*10000;
5219 break;
5220 case IDATAHXSZ:
5221 if(unsigned(ri->idata) >= MAXITEMS)
5222 {
5223 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5224 ret = -10000;
5225 break;
5226 }
5227 ret=(itemsbuf[ri->idata].hxsz)*10000;
5228 break;
5229 case IDATAHYSZ:
5230 if(unsigned(ri->idata) >= MAXITEMS)
5231 {
5232 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5233 ret = -10000;
5234 break;
5235 }
5236 ret=(itemsbuf[ri->idata].hysz)*10000;
5237 break;
5238 case IDATAHZSZ:
5239 if(unsigned(ri->idata) >= MAXITEMS)
5240 {
5241 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5242 ret = -10000;
5243 break;
5244 }
5245 ret=(itemsbuf[ri->idata].hzsz)*10000;
5246 break;
5247 case IDATADXOFS:
5248 if(unsigned(ri->idata) >= MAXITEMS)
5249 {
5250 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5251 ret = -10000;
5252 break;
5253 }
5254 ret=(itemsbuf[ri->idata].xofs)*10000;
5255 break;
5256 case IDATADYOFS:
5257 if(unsigned(ri->idata) >= MAXITEMS)
5258 {
5259 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5260 ret = -10000;
5261 break;
5262 }
5263 ret=(itemsbuf[ri->idata].yofs)*10000;
5264 break;
5265 case IDATATILEW:
5266 if(unsigned(ri->idata) >= MAXITEMS)
5267 {
5268 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5269 ret = -10000;
5270 break;
5271 }
5272 ret=(itemsbuf[ri->idata].tilew)*10000;
5273 break;
5274 case IDATATILEH:
5275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(unsigned(ri->idata) >= MAXITEMS)
5276 {
5277 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5278 ret = -10000;
5279 break;
5280 }
5281 53 ret=(itemsbuf[ri->idata].tileh)*10000;
5282 53 break;
5283 case IDATAPICKUP:
5284 if(unsigned(ri->idata) >= MAXITEMS)
5285 {
5286 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5287 ret = -10000;
5288 break;
5289 }
5290 ret=(itemsbuf[ri->idata].pickup)*10000;
5291 break;
5292 case IDATAOVERRIDEFL:
5293 if(unsigned(ri->idata) >= MAXITEMS)
5294 {
5295 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5296 ret = 0;
5297 break;
5298 }
5299 ret=(itemsbuf[ri->idata].overrideFLAGS)*10000;
5300 break;
5301
5302 case IDATATILEWWEAP:
5303 if(unsigned(ri->idata) >= MAXITEMS)
5304 {
5305 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5306 ret = -10000;
5307 break;
5308 }
5309 ret=(itemsbuf[ri->idata].weap_tilew)*10000;
5310 break;
5311 case IDATATILEHWEAP:
5312 if(unsigned(ri->idata) >= MAXITEMS)
5313 {
5314 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5315 ret = -10000;
5316 break;
5317 }
5318 ret=(itemsbuf[ri->idata].weap_tileh)*10000;
5319 break;
5320 case IDATAOVERRIDEFLWEAP:
5321 if(unsigned(ri->idata) >= MAXITEMS)
5322 {
5323 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5324 ret = 0;
5325 break;
5326 }
5327 ret=(itemsbuf[ri->idata].weapoverrideFLAGS)*10000;
5328 break;
5329
5330 case IDATAFAMILY:
5331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1751295 times.
1751295 if(unsigned(ri->idata) >= MAXITEMS)
5332 {
5333 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5334 ret = -10000;
5335 break;
5336 }
5337 1751295 ret=(itemsbuf[ri->idata].family)*10000;
5338 1751295 break;
5339
5340 case IDATALEVEL:
5341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14532 times.
14532 if(unsigned(ri->idata) >= MAXITEMS)
5342 {
5343 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5344 ret = -10000;
5345 break;
5346 }
5347 14532 ret=(itemsbuf[ri->idata].fam_type)*10000;
5348 14532 break;
5349
5350 case IDATAKEEP:
5351 ret = item_flag(ITEM_GAMEDATA);
5352 break;
5353
5354 case IDATAAMOUNT:
5355 {
5356 if(unsigned(ri->idata) >= MAXITEMS)
5357 {
5358 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5359 ret = -10000;
5360 break;
5361 }
5362 int32_t v = itemsbuf[ri->idata].amount;
5363 ret = ((v&0x4000)?-1:1)*(v & 0x3FFF)*10000;
5364 break;
5365 }
5366 case IDATAGRADUAL:
5367 {
5368 if(unsigned(ri->idata) >= MAXITEMS)
5369 {
5370 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5371 ret = -10000;
5372 break;
5373 }
5374 ret = (itemsbuf[ri->idata].amount&0x8000) ? 10000 : 0;
5375 break;
5376 }
5377 case IDATACONSTSCRIPT:
5378 ret = item_flag(ITEM_PASSIVESCRIPT);
5379 break;
5380 case IDATASSWIMDISABLED:
5381 ret = item_flag(ITEM_SIDESWIM_DISABLED);
5382 break;
5383 case IDATABUNNYABLE:
5384 ret = item_flag(ITEM_BUNNY_ENABLED);
5385 break;
5386 case IDATAJINXIMMUNE:
5387 ret = item_flag(ITEM_JINX_IMMUNE);
5388 break;
5389 case IDATAJINXSWAP:
5390 ret = item_flag(ITEM_FLIP_JINX);
5391 break;
5392
5393 case IDATASETMAX:
5394 if(unsigned(ri->idata) >= MAXITEMS)
5395 {
5396 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5397 ret = -10000;
5398 break;
5399 }
5400 ret=(itemsbuf[ri->idata].setmax)*10000;
5401 break;
5402
5403 case IDATAMAX:
5404 if(unsigned(ri->idata) >= MAXITEMS)
5405 {
5406 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5407 ret = -10000;
5408 break;
5409 }
5410 ret=(itemsbuf[ri->idata].max)*10000;
5411 break;
5412
5413 case IDATACOUNTER:
5414 if(unsigned(ri->idata) >= MAXITEMS)
5415 {
5416 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5417 ret = -10000;
5418 break;
5419 }
5420 ret=(itemsbuf[ri->idata].count)*10000;
5421 break;
5422
5423 case IDATAPSOUND:
5424 if(unsigned(ri->idata) >= MAXITEMS)
5425 {
5426 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5427 ret = -10000;
5428 break;
5429 }
5430 ret=(itemsbuf[ri->idata].playsound)*10000;
5431 break;
5432 case IDATAUSESOUND:
5433 if(unsigned(ri->idata) >= MAXITEMS)
5434 {
5435 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5436 ret = -10000;
5437 break;
5438 }
5439 ret=(itemsbuf[ri->idata].usesound)*10000;
5440 break;
5441
5442 case IDATAUSESOUND2:
5443 if(unsigned(ri->idata) >= MAXITEMS)
5444 {
5445 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5446 ret = -10000;
5447 break;
5448 }
5449 ret=(itemsbuf[ri->idata].usesound2)*10000;
5450 break;
5451
5452 case IDATAPOWER:
5453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(unsigned(ri->idata) >= MAXITEMS)
5454 {
5455 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5456 ret = -10000;
5457 break;
5458 }
5459 140 ret=(itemsbuf[ri->idata].power)*10000;
5460 140 break;
5461
5462 //Get the ID of an item.
5463 case IDATAID:
5464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1765 times.
1765 if(unsigned(ri->idata) >= MAXITEMS)
5465 {
5466 //Don't error here //Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5467 ret = -10000;
5468 break;
5469 }
5470 1765 ret=ri->idata*10000;
5471 1765 break;
5472
5473 //Get the script assigned to an item (active)
5474 case IDATASCRIPT:
5475 if(unsigned(ri->idata) >= MAXITEMS)
5476 {
5477 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5478 ret = -10000;
5479 break;
5480 }
5481 ret=(itemsbuf[ri->idata].script)*10000;
5482 break;
5483 case IDATASPRSCRIPT:
5484 if(unsigned(ri->idata) >= MAXITEMS)
5485 {
5486 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5487 ret = -10000;
5488 break;
5489 }
5490 ret=(itemsbuf[ri->idata].sprite_script)*10000;
5491 break;
5492 //Get the ->Attributes[] of an item
5493 case IDATAATTRIB:
5494 {
5495 if(unsigned(ri->idata) >= MAXITEMS)
5496 {
5497 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5498 ret = -10000;
5499 break;
5500 }
5501 int32_t index = vbound(ri->d[rINDEX]/10000,0,9);
5502 switch(index)
5503 {
5504 case 0:
5505 ret=(itemsbuf[ri->idata].misc1)*10000; break;
5506 case 1:
5507 ret=(itemsbuf[ri->idata].misc2)*10000; break;
5508 case 2:
5509 ret=(itemsbuf[ri->idata].misc3)*10000; break;
5510 case 3:
5511 ret=(itemsbuf[ri->idata].misc4)*10000; break;
5512 case 4:
5513 ret=(itemsbuf[ri->idata].misc5)*10000; break;
5514 case 5:
5515 ret=(itemsbuf[ri->idata].misc6)*10000; break;
5516 case 6:
5517 ret=(itemsbuf[ri->idata].misc7)*10000; break;
5518 case 7:
5519 ret=(itemsbuf[ri->idata].misc8)*10000; break;
5520 case 8:
5521 ret=(itemsbuf[ri->idata].misc9)*10000; break;
5522 case 9:
5523 ret=(itemsbuf[ri->idata].misc10)*10000; break;
5524 default:
5525 ret = -10000; break;
5526 }
5527
5528 break;
5529 }
5530 //Get the ->Sprite[] of an item.
5531 case IDATASPRITE:
5532 {
5533 if(unsigned(ri->idata) >= MAXITEMS)
5534 {
5535 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5536 ret = -10000;
5537 break;
5538 }
5539 int32_t index = vbound(ri->d[rINDEX]/10000,0,9);
5540 switch(index)
5541 {
5542 case 0:
5543 ret=(itemsbuf[ri->idata].wpn)*10000; break;
5544 case 1:
5545 ret=(itemsbuf[ri->idata].wpn2)*10000; break;
5546 case 2:
5547 ret=(itemsbuf[ri->idata].wpn3)*10000; break;
5548 case 3:
5549 ret=(itemsbuf[ri->idata].wpn4)*10000; break;
5550 case 4:
5551 ret=(itemsbuf[ri->idata].wpn5)*10000; break;
5552 case 5:
5553 ret=(itemsbuf[ri->idata].wpn6)*10000; break;
5554 case 6:
5555 ret=(itemsbuf[ri->idata].wpn7)*10000; break;
5556 case 7:
5557 ret=(itemsbuf[ri->idata].wpn8)*10000; break;
5558 case 8:
5559 ret=(itemsbuf[ri->idata].wpn9)*10000; break;
5560 case 9:
5561 ret=(itemsbuf[ri->idata].wpn10)*10000; break;
5562 default:
5563 ret = -10000; break;
5564 }
5565
5566 break;
5567 }
5568 //Hero TIle modifier
5569 case IDATALTM:
5570 if(unsigned(ri->idata) >= MAXITEMS)
5571 {
5572 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5573 ret = 0;
5574 break;
5575 }
5576 ret=(itemsbuf[ri->idata].ltm)*10000;
5577 break;
5578 //Pickup script
5579 case IDATAPSCRIPT:
5580 if(unsigned(ri->idata) >= MAXITEMS)
5581 {
5582 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5583 ret = -10000;
5584 break;
5585 }
5586 ret=(itemsbuf[ri->idata].collect_script)*10000;
5587 break;
5588 //Pickup string
5589 case IDATAPSTRING:
5590 if(unsigned(ri->idata) >= MAXITEMS)
5591 {
5592 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5593 ret = -10000;
5594 break;
5595 }
5596 ret=(itemsbuf[ri->idata].pstring)*10000;
5597 break;
5598 case IDATAPFLAGS:
5599 if(unsigned(ri->idata) >= MAXITEMS)
5600 {
5601 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5602 ret = 0;
5603 break;
5604 }
5605 ret=(itemsbuf[ri->idata].pickup_string_flags)*10000;
5606 break;
5607 //Magic cost
5608 case IDATAMAGCOST:
5609 if(unsigned(ri->idata) >= MAXITEMS)
5610 {
5611 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5612 ret = -10000;
5613 break;
5614 }
5615 ret=(itemsbuf[ri->idata].cost_amount[0])*10000;
5616 break;
5617 case IDATACOST2:
5618 if(unsigned(ri->idata) >= MAXITEMS)
5619 {
5620 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5621 ret = -10000;
5622 break;
5623 }
5624 ret=(itemsbuf[ri->idata].cost_amount[1])*10000;
5625 break;
5626 //cost counter ref
5627 case IDATACOSTCOUNTER:
5628 if(unsigned(ri->idata) >= MAXITEMS)
5629 {
5630 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5631 ret = -10000;
5632 break;
5633 }
5634 ret=(itemsbuf[ri->idata].cost_counter[0])*10000;
5635 break;
5636 case IDATACOSTCOUNTER2:
5637 if(unsigned(ri->idata) >= MAXITEMS)
5638 {
5639 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5640 ret = -10000;
5641 break;
5642 }
5643 ret=(itemsbuf[ri->idata].cost_counter[1])*10000;
5644 break;
5645 //Min Hearts to Pick Up
5646 case IDATAMINHEARTS:
5647 if(unsigned(ri->idata) >= MAXITEMS)
5648 {
5649 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5650 ret = -10000;
5651 break;
5652 }
5653 ret=(itemsbuf[ri->idata].pickup_hearts)*10000;
5654 break;
5655 //Tile used by the item
5656 case IDATATILE:
5657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55501 times.
55501 if(unsigned(ri->idata) >= MAXITEMS)
5658 {
5659 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5660 ret = -10000;
5661 break;
5662 }
5663 55501 ret=(itemsbuf[ri->idata].tile)*10000;
5664 55501 break;
5665 //itemdata->Flash
5666 case IDATAMISC:
5667 if(unsigned(ri->idata) >= MAXITEMS)
5668 {
5669 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5670 ret = -10000;
5671 break;
5672 }
5673 ret=(itemsbuf[ri->idata].misc_flags)*10000;
5674 break;
5675 //->CSet
5676 case IDATACSET:
5677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55501 times.
55501 if(unsigned(ri->idata) >= MAXITEMS)
5678 {
5679 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5680 ret = -10000;
5681 break;
5682 }
5683 55501 ret=(itemsbuf[ri->idata].csets)*10000;
5684 55501 break;
5685 //->A.Frames
5686 case IDATAFRAMES:
5687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63041 times.
63041 if(unsigned(ri->idata) >= MAXITEMS)
5688 {
5689 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5690 ret = -10000;
5691 break;
5692 }
5693 63041 ret=(itemsbuf[ri->idata].frames)*10000;
5694 63041 break;
5695 /*
5696 case IDATAFRAME:
5697 ret=(itemsbuf[ri->idata].frame)*10000;
5698 break;
5699 */
5700 //->A.Speed
5701 case IDATAASPEED:
5702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142873 times.
142873 if(unsigned(ri->idata) >= MAXITEMS)
5703 {
5704 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5705 ret = -10000;
5706 break;
5707 }
5708 142873 ret=(itemsbuf[ri->idata].speed)*10000;
5709 142873 break;
5710 //->Delay
5711 case IDATADELAY:
5712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74538 times.
74538 if(unsigned(ri->idata) >= MAXITEMS)
5713 {
5714 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5715 ret = -10000;
5716 break;
5717 }
5718 74538 ret=(itemsbuf[ri->idata].delay)*10000;
5719 74538 break;
5720 // teo of this item upgrades
5721 case IDATACOMBINE:
5722 ret = item_flag(ITEM_COMBINE);
5723 break;
5724 //Use item, and get the lower level one
5725 case IDATADOWNGRADE:
5726 ret = item_flag(ITEM_DOWNGRADE);
5727 break;
5728 //Only validate the cost, don't charge it
5729 case IDATAVALIDATE:
5730 ret = item_flag(ITEM_VALIDATEONLY);
5731 break;
5732 case IDATAVALIDATE2:
5733 ret = item_flag(ITEM_VALIDATEONLY2);
5734 break;
5735 //->Flags[5]
5736 case IDATAFLAGS:
5737 {
5738 if(unsigned(ri->idata) >= MAXITEMS)
5739 {
5740 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5741 ret = 0;
5742 break;
5743 }
5744 int32_t index = ri->d[rINDEX]/10000;
5745 switch(index)
5746 {
5747 case 0:
5748 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG1)?10000:0; break;
5749 case 1:
5750 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG2)?10000:0; break;
5751 case 2:
5752 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG3)?10000:0; break;
5753 case 3:
5754 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG4)?10000:0; break;
5755 case 4:
5756 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG5)?10000:0; break;
5757 case 5:
5758 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG6)?10000:0; break;
5759 case 6:
5760 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG7)?10000:0; break;
5761 case 7:
5762 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG8)?10000:0; break;
5763 case 8:
5764 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG9)?10000:0; break;
5765 case 9:
5766 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG10)?10000:0; break;
5767 case 10:
5768 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG11)?10000:0; break;
5769 case 11:
5770 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG12)?10000:0; break;
5771 case 12:
5772 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG13)?10000:0; break;
5773 case 13:
5774 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG14)?10000:0; break;
5775 case 14:
5776 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG15)?10000:0; break;
5777 case 15:
5778 ret=(itemsbuf[ri->idata].flags & ITEM_PASSIVESCRIPT)?10000:0; break;
5779
5780
5781 default:
5782 Z_scripterrlog("Invalid itemdata->Flags[] index: %d\n", index);
5783 ret = 0;
5784 break;
5785 }
5786 break;
5787 }
5788
5789 //->Keep Old
5790 case IDATAKEEPOLD:
5791 ret = item_flag(ITEM_KEEPOLD);
5792 break;
5793 //Use rupees instead of magic
5794 case IDATARUPEECOST:
5795 ret = item_flag(ITEM_RUPEE_MAGIC);
5796 break;
5797 //Can be eaten
5798 case IDATAEDIBLE:
5799 ret = item_flag(ITEM_EDIBLE);
5800 break;
5801 //currently unused
5802 case IDATAFLAGUNUSED:
5803 ret = item_flag(ITEM_UNUSED);
5804 break;
5805 //Gain lower level items when collected
5806 case IDATAGAINLOWER:
5807 ret = item_flag(ITEM_GAINOLD);
5808 break;
5809 //Unchanged from master
5810 case IDATAINITDD:
5811 {
5812 int32_t a = ri->d[rINDEX] / 10000;
5813 if(unsigned(ri->idata) >= MAXITEMS)
5814 {
5815 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5816 ret = -10000;
5817 break;
5818 }
5819
5820 if(BC::checkBounds(a, 0, 7, "itemdata->InitD") != SH::_NoError)
5821 ret = -10000;
5822 else
5823 ret = itemsbuf[ri->idata].initiald[a];
5824 }
5825 break;
5826
5827 ///----------------------------------------------------------------------------------------------------//
5828 //NPC Variables
5829
5830 //Reduces accessing integer members to one line
5831 #define GET_NPC_VAR_INT(member, str) \
5832 { \
5833 if(GuyH::loadNPC(ri->guyref, str) != SH::_NoError) \
5834 ret = -10000; \
5835 else \
5836 ret = GuyH::getNPC()->member * 10000; \
5837 }
5838
5839 case NPCDIR:
5840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77690 times.
77690 if(GuyH::loadNPC(ri->guyref, "npc->Dir") != SH::_NoError)
5841 ret = -10000;
5842 else
5843
2/2
✓ Branch 0 taken 72477 times.
✓ Branch 1 taken 5213 times.
77690 ret = zc_max(GuyH::getNPC()->dir * 10000, 0);
5844
5845 77690 break;
5846
5847 case NPCHITDIR:
5848 if(GuyH::loadNPC(ri->guyref, "npc->HitDir") != SH::_NoError)
5849 ret = -10000;
5850 else
5851 ret = (GuyH::getNPC()->hitdir * 10000);
5852
5853 break;
5854
5855 case NPCSLIDECLK:
5856 if(GuyH::loadNPC(ri->guyref, "npc->SlideClock") != SH::_NoError)
5857 ret = -10000;
5858 else
5859 ret = (GuyH::getNPC()->sclk * 10000);
5860
5861 break;
5862
5863 case NPCHALTCLK:
5864 if(GuyH::loadNPC(ri->guyref, "npc->Halt") != SH::_NoError)
5865 ret = -10000;
5866 else
5867 ret = (GuyH::getNPC()->clk2 * 10000);
5868
5869 break;
5870
5871 case NPCFRAME:
5872 if(GuyH::loadNPC(ri->guyref, "npc->Frame") != SH::_NoError)
5873 ret = -10000;
5874 else
5875 ret = (GuyH::getNPC()->clk * 10000);
5876
5877 break;
5878
5879 case NPCMOVESTATUS:
5880 if(GuyH::loadNPC(ri->guyref, "npc->MoveStatus") != SH::_NoError)
5881 ret = -10000;
5882 else
5883 ret = (GuyH::getNPC()->movestatus * 10000);
5884
5885 break;
5886
5887 case NPCFADING:
5888 if(GuyH::loadNPC(ri->guyref, "npc->Fading") != SH::_NoError)
5889 ret = -10000;
5890 else
5891 ret = (GuyH::getNPC()->fading * 10000);
5892
5893 break;
5894
5895 case NPCRATE:
5896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 426414 times.
426414 GET_NPC_VAR_INT(rate, "npc->Rate") break;
5897
5898 case NPCHOMING:
5899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 436097 times.
436097 GET_NPC_VAR_INT(homing, "npc->Homing") break;
5900
5901 case NPCFRAMERATE:
5902 GET_NPC_VAR_INT(frate, "npc->ASpeed") break;
5903
5904 case NPCHALTRATE:
5905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410674 times.
410674 GET_NPC_VAR_INT(hrate, "npc->HaltRate") break;
5906
5907 case NPCRANDOM:
5908 GET_NPC_VAR_INT(rate, "npc->Random") break;
5909
5910 case NPCDRAWTYPE:
5911 GET_NPC_VAR_INT(drawstyle, "npc->DrawStyle") break;
5912
5913 case NPCHP:
5914
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5123276 times.
5123278 GET_NPC_VAR_INT(hp, "npc->HP") break;
5915
5916 case NPCORIGINALHP:
5917 GET_NPC_VAR_INT(starting_hp, "npc->OriginalHP") break;
5918
5919 case NPCCOLLDET:
5920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165739 times.
165739 GET_NPC_VAR_INT(scriptcoldet, "npc->ColDetection") break;
5921
5922 case NPCENGINEANIMATE:
5923 GET_NPC_VAR_INT(do_animation, "npc->Animation") break;
5924
5925 case NPCSTUN:
5926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1128791 times.
1128791 GET_NPC_VAR_INT(stunclk, "npc->Stun") break;
5927
5928 case NPCHUNGER:
5929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472577 times.
472577 GET_NPC_VAR_INT(grumble, "npc->Hunger") break;
5930
5931 case NPCWEAPSPRITE:
5932 GET_NPC_VAR_INT(wpnsprite, "npc->WeaponSprite") break;
5933
5934 case NPCTYPE:
5935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532410 times.
532410 GET_NPC_VAR_INT(family, "npc->Type") break;
5936
5937 case NPCDP:
5938
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3165 times.
3169 GET_NPC_VAR_INT(dp, "npc->Damage") break;
5939
5940 case NPCWDP:
5941
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 12956 times.
13200 GET_NPC_VAR_INT(wdp, "npc->WeaponDamage") break;
5942
5943 case NPCOTILE:
5944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5408 times.
5408 GET_NPC_VAR_INT(o_tile, "npc->OriginalTile") break;
5945
5946 case NPCTILE:
5947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39139 times.
39139 GET_NPC_VAR_INT(tile, "npc->Tile") break;
5948
5949 case NPCSCRIPTTILE:
5950 GET_NPC_VAR_INT(scripttile, "npc->ScriptTile") break;
5951
5952 case NPCSCRIPTFLIP:
5953 GET_NPC_VAR_INT(scriptflip, "npc->ScriptFlip") break;
5954
5955 case NPCWEAPON:
5956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 404 times.
404 GET_NPC_VAR_INT(wpn, "npc->Weapon") break;
5957
5958 case NPCITEMSET:
5959 GET_NPC_VAR_INT(item_set, "npc->ItemSet") break;
5960
5961 case NPCCSET:
5962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17986 times.
17986 GET_NPC_VAR_INT(cs, "npc->CSet") break;
5963
5964 case NPCBOSSPAL:
5965 GET_NPC_VAR_INT(bosspal, "npc->BossPal") break;
5966
5967 case NPCBGSFX:
5968 GET_NPC_VAR_INT(bgsfx, "npc->SFX") break;
5969
5970 case NPCEXTEND:
5971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6086 times.
6086 GET_NPC_VAR_INT(extend, "npc->Extend") break;
5972
5973 case NPCHXOFS:
5974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383015 times.
383015 GET_NPC_VAR_INT(hxofs, "npc->HitXOffset") break;
5975
5976 case NPCHYOFS:
5977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383015 times.
383015 GET_NPC_VAR_INT(hyofs, "npc->HitYOffset") break;
5978
5979 case NPCHXSZ:
5980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 427914 times.
427914 GET_NPC_VAR_INT(hit_width, "npc->HitWidth") break;
5981
5982 case NPCHYSZ:
5983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 427914 times.
427914 GET_NPC_VAR_INT(hit_height, "npc->HitHeight") break;
5984
5985 case NPCHZSZ:
5986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226198 times.
226198 GET_NPC_VAR_INT(hzsz, "npc->HitZHeight") break;
5987
5988 case NPCROTATION:
5989 if ( get_qr(qr_OLDSPRITEDRAWS) )
5990 {
5991 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
5992 "npc->Rotation");
5993 ret = -1; break;
5994 }
5995 GET_NPC_VAR_INT(rotation, "npc->Rotation") break;
5996
5997 case NPCTXSZ:
5998
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1503636 times.
1504060 GET_NPC_VAR_INT(txsz, "npc->TileWidth") break;
5999
6000 case NPCTYSZ:
6001
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1485761 times.
1486185 GET_NPC_VAR_INT(tysz, "npc->TileHeight") break;
6002
6003 //And zfix
6004 #define GET_NPC_VAR_FIX(member, str) \
6005 { \
6006 if(GuyH::loadNPC(ri->guyref, str) != SH::_NoError) \
6007 { \
6008 ret = -10000; \
6009 break; \
6010 } \
6011 else \
6012 ret = (int32_t(GuyH::getNPC()->member) * 10000); \
6013 }
6014
6015 case NPCX:
6016 //GET_NPC_VAR_FIX(x, "npc->X") break;
6017 {
6018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1058431 times.
1058431 if(GuyH::loadNPC(ri->guyref, "X") != SH::_NoError)
6019 {
6020 ret = -10000;
6021 }
6022 else
6023 {
6024
2/2
✓ Branch 0 taken 11121 times.
✓ Branch 1 taken 1047310 times.
1058431 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6025 {
6026 11121 ret = ((GuyH::getNPC()->x).getZLong());
6027 11121 }
6028 else
6029 {
6030 1047310 ret = (int32_t(GuyH::getNPC()->x) * 10000);
6031 }
6032 }
6033 1058431 break;
6034 }
6035
6036 case SPRITEMAXNPC:
6037 {
6038 //No bounds check, as this is a universal function and works from NULL pointers!
6039 ret = guys.getMax() * 10000;
6040 break;
6041 }
6042
6043 case NPCSUBMERGED:
6044 {
6045 if(GuyH::loadNPC(ri->guyref, "Submerged()") != SH::_NoError)
6046 {
6047 ret = -10000;
6048 }
6049 else
6050 {
6051 ret = ((GuyH::getNPC()->isSubmerged()) ? 10000 : 0);
6052
6053 }
6054 break;
6055 }
6056
6057
6058 case NPCY:
6059 //GET_NPC_VAR_FIX(y, "npc->Y") break;
6060 {
6061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1035972 times.
1035972 if(GuyH::loadNPC(ri->guyref, "Y") != SH::_NoError)
6062 {
6063 ret = -10000;
6064 }
6065 else
6066 {
6067
2/2
✓ Branch 0 taken 11120 times.
✓ Branch 1 taken 1024852 times.
1035972 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6068 {
6069 11120 ret = ((GuyH::getNPC()->y).getZLong());
6070 11120 }
6071 else
6072 {
6073 1024852 ret = (int32_t(GuyH::getNPC()->y) * 10000);
6074 }
6075 }
6076 1035972 break;
6077 }
6078
6079
6080 case NPCZ:
6081 //GET_NPC_VAR_FIX(z, "npc->Z") break;
6082 {
6083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 603413 times.
603413 if(GuyH::loadNPC(ri->guyref, "Z") != SH::_NoError)
6084 {
6085 ret = -10000;
6086 }
6087 else
6088 {
6089
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 602857 times.
603413 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6090 {
6091 556 ret = ((GuyH::getNPC()->z).getZLong());
6092 556 }
6093 else
6094 {
6095 602857 ret = (int32_t(GuyH::getNPC()->z) * 10000);
6096 }
6097 }
6098 603413 break;
6099 }
6100
6101 case NPCXOFS:
6102
1/2
✓ Branch 0 taken 2061476 times.
✗ Branch 1 not taken.
2061476 GET_NPC_VAR_FIX(xofs, "npc->DrawXOffset") break;
6103
6104 case NPCYOFS:
6105
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2062453 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2062453 times.
2062453 GET_NPC_VAR_FIX(yofs, "npc->DrawYOffset") ret-=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)*10000;
6106 2062453 break;
6107 case NPCSHADOWXOFS:
6108 GET_NPC_VAR_FIX(shadowxofs, "npc->ShadowXOffset") break;
6109
6110 case NPCSHADOWYOFS:
6111 GET_NPC_VAR_FIX(shadowyofs, "npc->ShadowYOffset") break;
6112
6113 case NPCTOTALDYOFFS:
6114 {
6115 if(GuyH::loadNPC(ri->guyref, "npc->TotalDYOffset") != SH::_NoError)
6116 {
6117 ret = -10000;
6118 }
6119 else
6120 {
6121 ret = ((int32_t(GuyH::getNPC()->yofs - (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset))
6122 + ((GuyH::getNPC()->switch_hooked && Hero.switchhookstyle == swRISE)
6123 ? -(8-(abs(Hero.switchhookclk-32)/4)) : 0)) * 10000);
6124 }
6125 break;
6126 }
6127
6128 case NPCZOFS:
6129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2061449 times.
2061449 GET_NPC_VAR_FIX(zofs, "npc->DrawZOffset") break;
6130
6131 //These variables are all different to the templates (casting for jump and step is slightly non-standard)
6132 case NPCJUMP:
6133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75622 times.
75622 if(GuyH::loadNPC(ri->guyref, "npc->Jump") != SH::_NoError)
6134 ret = -10000;
6135 else
6136 {
6137 75622 ret = GuyH::getNPC()->fall.getZLong() / -100;
6138
2/2
✓ Branch 0 taken 278 times.
✓ Branch 1 taken 75344 times.
75622 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
6139 }
6140
6141 75622 break;
6142
6143 case NPCFAKEJUMP:
6144 if(GuyH::loadNPC(ri->guyref, "npc->FakeJump") != SH::_NoError)
6145 ret = -10000;
6146 else
6147 {
6148 ret = GuyH::getNPC()->fakefall.getZLong() / -100;
6149 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
6150 }
6151
6152 break;
6153
6154
6155 case NPCSCALE:
6156 if ( get_qr(qr_OLDSPRITEDRAWS) )
6157 {
6158 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
6159 "npc->Scale");
6160 ret = -1; break;
6161 }
6162 if(GuyH::loadNPC(ri->guyref, "npc->Scale") != SH::_NoError)
6163 ret = -10000;
6164 else
6165 ret = (int32_t(GuyH::getNPC()->scale) * 100.0);
6166
6167 break;
6168
6169 case NPCIMMORTAL:
6170 if(GuyH::loadNPC(ri->guyref, "npc->Immortal") != SH::_NoError)
6171 ret = -10000;
6172 else
6173 ret = GuyH::getNPC()->immortal ? 10000 : 0;
6174 break;
6175
6176 case NPCNOSLIDE:
6177 if(GuyH::loadNPC(ri->guyref, "npc->NoSlide") != SH::_NoError)
6178 ret = -10000;
6179 else
6180 ret = (GuyH::getNPC()->knockbackflags & FLAG_NOSLIDE) ? 10000 : 0;
6181 break;
6182
6183 case NPCNOSCRIPTKB:
6184 if(GuyH::loadNPC(ri->guyref, "npc->NoScriptKnockback") != SH::_NoError)
6185 ret = -10000;
6186 else
6187 ret = (GuyH::getNPC()->knockbackflags & FLAG_NOSCRIPTKNOCKBACK) ? 10000 : 0;
6188 break;
6189
6190 case NPCKNOCKBACKSPEED:
6191 if(GuyH::loadNPC(ri->guyref, "npc->SlideSpeed") != SH::_NoError)
6192 ret = -10000;
6193 else
6194 ret = GuyH::getNPC()->knockbackSpeed * 10000;
6195 break;
6196
6197 case NPCSTEP:
6198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527244 times.
527244 if(GuyH::loadNPC(ri->guyref, "npc->Step") != SH::_NoError)
6199 ret = -10000;
6200 else
6201 {
6202
3/4
✓ Branch 0 taken 487718 times.
✓ Branch 1 taken 39526 times.
✓ Branch 2 taken 487718 times.
✗ Branch 3 not taken.
527244 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
6203 {
6204 527244 ret = ( ( (GuyH::getNPC()->step).getZLong() ) * 100 );
6205 527244 }
6206 //old, buggy code replication, round two: Go! -Z
6207 //else ret = ( ( (GuyH::getNPC()->step) * 100.0 ).getZLong() );
6208 else
6209 {
6210 double s2 = ( (GuyH::getNPC()->step).getZLong() );
6211 ret = int32_t(s2*100);
6212 //ret = int32_t( ( (GuyH::getNPC()->step) * 100.0 )) * 10000;
6213 }
6214 //else ret = int32_t(GuyH::getNPC()->step * fix(100.0)) * 10000;
6215
6216 //else
6217 //{
6218 //old, buggy code replication, round THREE: Go! -Z
6219 // double tmp = ( (GuyH::getNPC()->step) ) * 1000000.0;
6220 // ret = (int32_t)tmp;
6221 //}
6222 }
6223
6224 527244 break;
6225
6226 case NPCGRAVITY:
6227 if(GuyH::loadNPC(ri->guyref, "npc->Gravity") != SH::_NoError)
6228 ret = -10000;
6229 else
6230 ret = ((GuyH::getNPC()->moveflags & FLAG_OBEYS_GRAV) ? 10000 : 0);
6231
6232 break;
6233
6234
6235 case NPCID:
6236
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 22516406 times.
22516459 if(GuyH::loadNPC(ri->guyref, "npc->ID") != SH::_NoError)
6237 53 ret = -10000;
6238 else
6239 22516406 ret = (GuyH::getNPC()->id & 0xFFF) * 10000;
6240
6241 22516459 break;
6242
6243 case NPCISCORE:
6244 if(GuyH::loadNPC(ri->guyref, "npc->isCore") != SH::_NoError)
6245 ret = -10000;
6246 else
6247 ret = ((GuyH::getNPC()->isCore) ? 10000 : 0);
6248
6249 break;
6250
6251 case NPCSCRIPTUID:
6252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 598 times.
598 if(GuyH::loadNPC(ri->guyref, "npc->ScriptUID") != SH::_NoError)
6253 ret = -10000;
6254 else
6255 598 ret = ((GuyH::getNPC()->getScriptUID())); //literal, not *10000
6256
6257 598 break;
6258
6259 case NPCPARENTUID:
6260 if(GuyH::loadNPC(ri->guyref, "npc->ParentUID") != SH::_NoError)
6261 ret = -10000;
6262 else
6263 ret = ((GuyH::getNPC()->parent_script_UID)); //literal, not *10000
6264
6265 break;
6266
6267 //case EWPNPARENTUID:
6268 //if(0!=(s=checkEWpn(ri->ewpn, "ScriptUID")))
6269 // ret=(((weapon*)(s))->parent_script_UID); //literal, not *10000
6270
6271
6272 case NPCMFLAGS:
6273
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 3669986 times.
3670410 if(GuyH::loadNPC(ri->guyref, "npc->MiscFlags") != SH::_NoError)
6274 424 ret = -10000;
6275 else
6276 3669986 ret = GuyH::getMFlags() * 10000;
6277
6278 3670410 break;
6279
6280 //Indexed (two checks)
6281 case NPCDEFENSED:
6282 {
6283 167669 int32_t a = ri->d[rINDEX] / 10000;
6284
6285
2/4
✓ Branch 0 taken 167669 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 167669 times.
167669 if(GuyH::loadNPC(ri->guyref, "npc->Defense[]") != SH::_NoError ||
6286 167669 BC::checkBounds(a, 0, (edefLAST255), "npc->Defense[]") != SH::_NoError)
6287 ret = -10000;
6288 else
6289 167669 ret = GuyH::getNPC()->defense[a] * 10000;
6290 }
6291 167669 break;
6292
6293 case NPCHITBY:
6294 {
6295 268246 int32_t indx = ri->d[rINDEX] / 10000;
6296
6297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 268246 times.
268246 if(GuyH::loadNPC(ri->guyref, "npc->HitBy[]") != SH::_NoError )
6298 {
6299 ret = -10000; break;
6300 }
6301 else
6302 {
6303
2/3
✓ Branch 0 taken 134123 times.
✓ Branch 1 taken 134123 times.
✗ Branch 2 not taken.
268246 switch(indx)
6304 {
6305 //screen indixes
6306 case 0:
6307 case 1:
6308 case 2:
6309 case 3:
6310 case 8:
6311 case 9:
6312 case 10:
6313 case 11:
6314 case 12:
6315 case 16:
6316 {
6317 134123 ret = GuyH::getNPC()->hitby[indx] * 10000; // * 10000; //do not multiply by 10000! UIDs are not *10000!
6318 134123 break;
6319 }
6320 //UIDs
6321 case 4:
6322 case 5:
6323 case 6:
6324 case 7:
6325 case 13:
6326 case 14:
6327 case 15:
6328 {
6329 134123 ret = GuyH::getNPC()->hitby[indx]; // * 10000; //do not multiply by 10000! UIDs are not *10000!
6330 134123 break;
6331 }
6332 default: { Z_scripterrlog("Invalid index used for npc->HitBy[%d]. /n", indx); ret = -10000; break; }
6333 }
6334 268246 break;
6335 }
6336 }
6337
6338 //2.fuure compat.
6339
6340 case NPCSCRDEFENSED:
6341 {
6342 int32_t a = ri->d[rINDEX] / 10000;
6343
6344 if(GuyH::loadNPC(ri->guyref, "npc->ScriptDefense") != SH::_NoError ||
6345 BC::checkBounds(a, 0, edefSCRIPTDEFS_MAX, "npc->ScriptDefense") != SH::_NoError)
6346 ret = -10000;
6347 else
6348 ret = GuyH::getNPC()->defense[a+edefSCRIPT01] * 10000;
6349 }
6350 break;
6351
6352
6353 case NPCMISCD:
6354 {
6355 11380654 int32_t a = ri->d[rINDEX] / 10000;
6356
6357
3/4
✓ Branch 0 taken 11380615 times.
✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11380615 times.
11380654 if(GuyH::loadNPC(ri->guyref, "npc->Misc") != SH::_NoError ||
6358 11380615 BC::checkMisc32(a, "npc->Misc") != SH::_NoError)
6359 39 ret = -10000;
6360 else
6361 11380615 ret = GuyH::getNPC()->miscellaneous[a];
6362 }
6363 11380654 break;
6364 case NPCINITD:
6365 {
6366 int32_t a = ri->d[rINDEX] / 10000;
6367
6368 if(GuyH::loadNPC(ri->guyref, "npc->InitD[]") != SH::_NoError )
6369 ret = -10000;
6370 else
6371 {
6372 //enemy *e = (enemy*)guys.spr(ri->guyref);
6373 ret = (int32_t)GuyH::getNPC()->initD[a];
6374 }
6375 }
6376 break;
6377
6378 case NPCSCRIPT:
6379 {
6380 if(GuyH::loadNPC(ri->guyref, "npc->Script") != SH::_NoError )
6381 ret = -10000;
6382 else
6383 {
6384 //enemy *e = (enemy*)guys.spr(ri->guyref);
6385 ret = (int32_t)GuyH::getNPC()->script * 10000;
6386 }
6387 }
6388 break;
6389
6390 case NPCDD: //Fized the size of this array. There are 15 total attribs, [0] to [14], not [0] to [9]. -Z
6391 {
6392 6431340 int32_t a = ri->d[rINDEX] / 10000;
6393
6394
2/4
✓ Branch 0 taken 6431340 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6431340 times.
6431340 if(GuyH::loadNPC(ri->guyref, "npc->Attributes") != SH::_NoError ||
6395 6431340 BC::checkBounds(a, 0, ( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 ? 31 : 15 ), "npc->Attributes") != SH::_NoError)
6396 ret = -10000;
6397 else
6398 6431340 ret = GuyH::getNPCDMisc(a) * 10000;
6399 }
6400 6431340 break;
6401
6402 case NPCINVINC:
6403 if(GuyH::loadNPC(ri->guyref, "npc->InvFrames") != SH::_NoError)
6404 ret = -10000;
6405 else
6406 ret = (int32_t)GuyH::getNPC()->hclk * 10000;
6407
6408 break;
6409
6410 case NPCHASITEM:
6411 if(GuyH::loadNPC(ri->guyref, "npc->HasItem") != SH::_NoError)
6412 ret = 0;
6413 else
6414 ret = GuyH::getNPC()->itemguy?10000:0;
6415
6416 break;
6417
6418 case NPCRINGLEAD:
6419 if(GuyH::loadNPC(ri->guyref, "npc->Ringleader") != SH::_NoError)
6420 ret = 0;
6421 else
6422 ret = GuyH::getNPC()->leader?10000:0;
6423
6424 break;
6425
6426 case NPCSUPERMAN:
6427 if(GuyH::loadNPC(ri->guyref, "npc->Invincible") != SH::_NoError)
6428 ret = -10000;
6429 else
6430 ret = (int32_t)GuyH::getNPC()->superman * 10000;
6431
6432 break;
6433
6434 case NPCSHIELD:
6435 {
6436 int32_t indx = ri->d[rINDEX];
6437 if(GuyH::loadNPC(ri->guyref, "npc->Shield[]") == SH::_NoError)
6438 {
6439 switch(indx)
6440 {
6441 case 0:
6442 {
6443 ret = ((GuyH::getNPC()->flags&inv_front) ? 10000 : 0);
6444 break;
6445 }
6446 case 1:
6447 {
6448 ret = ((GuyH::getNPC()->flags&inv_left) ? 10000 : 0);
6449 break;
6450 }
6451 case 2:
6452 {
6453 ret = ((GuyH::getNPC()->flags&inv_right) ? 10000 : 0);
6454 break;
6455 }
6456 case 3:
6457 {
6458 ret = ((GuyH::getNPC()->flags&inv_back) ? 10000 : 0);
6459 break;
6460 }
6461 case 4: //shield can be broken
6462 {
6463 ret = ((GuyH::getNPC()->flags&guy_bkshield) ? 10000 : 0);
6464 break;
6465 }
6466 default:
6467 {
6468 Z_scripterrlog("Invalid Array Index passed to npc->Shield[]: %d\n", indx);
6469 break;
6470 }
6471 }
6472 }
6473 else
6474 {
6475 ret = -10000;
6476 break;
6477 }
6478 }
6479 break;
6480
6481 case NPCFROZENTILE:
6482 GET_NPC_VAR_INT(frozentile, "npc->FrozenTile"); break;
6483
6484 case NPCFROZENCSET:
6485 GET_NPC_VAR_INT(frozencset, "npc->FrozenCSet"); break;
6486
6487 case NPCFROZEN:
6488 GET_NPC_VAR_INT(frozenclock, "npc->Frozen"); break;
6489
6490
6491 case NPCBEHAVIOUR:
6492 {
6493 if(GuyH::loadNPC(ri->guyref, "npc->Behaviour[]") != SH::_NoError)
6494 {
6495 ret = -10000;
6496 break;
6497 }
6498
6499 int32_t index = vbound(ri->d[rINDEX]/10000,0,4);
6500 switch(index)
6501 {
6502 case 0:
6503 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG1)?10000:0; break;
6504 case 1:
6505 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG2)?10000:0; break;
6506 case 2:
6507 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG3)?10000:0; break;
6508 case 3:
6509 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG4)?10000:0; break;
6510 case 4:
6511 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG5)?10000:0; break;
6512 case 5:
6513 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG6)?10000:0; break;
6514 case 6:
6515 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG7)?10000:0; break;
6516 case 7:
6517 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG8)?10000:0; break;
6518 case 8:
6519 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG9)?10000:0; break;
6520 case 9:
6521 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG10)?10000:0; break;
6522 case 10:
6523 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG11)?10000:0; break;
6524 case 11:
6525 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG12)?10000:0; break;
6526 case 12:
6527 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG13)?10000:0; break;
6528 case 13:
6529 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG14)?10000:0; break;
6530 case 14:
6531 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG15)?10000:0; break;
6532 case 15:
6533 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG16)?10000:0; break;
6534
6535 default:
6536 ret = 0; break;
6537 }
6538
6539 break;
6540 }
6541
6542 case NPCFALLCLK:
6543 if(GuyH::loadNPC(ri->guyref, "npc->Falling") == SH::_NoError)
6544 {
6545 ret = GuyH::getNPC()->fallclk * 10000;
6546 }
6547 break;
6548
6549 case NPCFALLCMB:
6550 if(GuyH::loadNPC(ri->guyref, "npc->FallCombo") == SH::_NoError)
6551 {
6552 ret = GuyH::getNPC()->fallCombo * 10000;
6553 }
6554 break;
6555
6556 case NPCDROWNCLK:
6557 if(GuyH::loadNPC(ri->guyref, "npc->Drowning") == SH::_NoError)
6558 {
6559 ret = GuyH::getNPC()->drownclk * 10000;
6560 }
6561 break;
6562
6563 case NPCDROWNCMB:
6564 if(GuyH::loadNPC(ri->guyref, "npc->DrownCombo") == SH::_NoError)
6565 {
6566 ret = GuyH::getNPC()->drownCombo * 10000;
6567 }
6568 break;
6569
6570 case NPCFAKEZ:
6571 {
6572 if(GuyH::loadNPC(ri->guyref, "FakeZ") != SH::_NoError)
6573 {
6574 ret = -10000;
6575 }
6576 else
6577 {
6578 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6579 {
6580 ret = ((GuyH::getNPC()->fakez).getZLong());
6581 }
6582 else
6583 {
6584 ret = (int32_t(GuyH::getNPC()->fakez) * 10000);
6585 }
6586 }
6587 break;
6588 }
6589
6590 case NPCMOVEFLAGS:
6591 {
6592 if(GuyH::loadNPC(ri->guyref, "npc->MoveFlags[]") == SH::_NoError)
6593 {
6594 int32_t indx = ri->d[rINDEX]/10000;
6595 if(BC::checkBounds(indx, 0, 15, "npc->MoveFlags[]") != SH::_NoError)
6596 ret = 0; //false
6597 else
6598 {
6599 //All bits, in order, of a single byte; just use bitwise
6600 ret = (GuyH::getNPC()->moveflags & (1<<indx)) ? 10000 : 0;
6601 }
6602 }
6603 break;
6604 }
6605
6606 case NPCGLOWRAD:
6607 if(GuyH::loadNPC(ri->guyref, "npc->LightRadius") == SH::_NoError)
6608 {
6609 ret = GuyH::getNPC()->glowRad * 10000;
6610 }
6611 break;
6612
6613 case NPCGLOWSHP:
6614 if(GuyH::loadNPC(ri->guyref, "npc->LightShape") == SH::_NoError)
6615 {
6616 ret = GuyH::getNPC()->glowShape * 10000;
6617 }
6618 break;
6619
6620 case NPCSHADOWSPR:
6621 if(GuyH::loadNPC(ri->guyref, "npc->ShadowSprite") == SH::_NoError)
6622 {
6623 ret = GuyH::getNPC()->spr_shadow * 10000;
6624 }
6625 break;
6626 case NPCSPAWNSPR:
6627 if(GuyH::loadNPC(ri->guyref, "npc->SpawnSprite") == SH::_NoError)
6628 {
6629 ret = GuyH::getNPC()->spr_spawn * 10000;
6630 }
6631 break;
6632 case NPCDEATHSPR:
6633 if(GuyH::loadNPC(ri->guyref, "npc->DeathSprite") == SH::_NoError)
6634 {
6635 ret = GuyH::getNPC()->spr_death * 10000;
6636 }
6637 break;
6638 case NPCSWHOOKED:
6639 if(GuyH::loadNPC(ri->guyref, "npc->SwitchHooked") == SH::_NoError)
6640 {
6641 ret = GuyH::getNPC()->switch_hooked ? 10000 : 0;
6642 }
6643 break;
6644 case NPCCANFLICKER:
6645 if(GuyH::loadNPC(ri->guyref, "npc->InvFlicker") == SH::_NoError)
6646 {
6647 ret = GuyH::getNPC()->getCanFlicker() ? 10000 : 0;
6648 }
6649 break;
6650
6651
6652
6653 ///----------------------------------------------------------------------------------------------------//
6654 //LWeapon Variables
6655 case LWPNSPECIAL:
6656 if(0!=(s=checkLWpn(ri->lwpn,"Special")))
6657 ret=((int32_t)((weapon*)(s))->specialinfo)*10000;
6658
6659
6660 break;
6661
6662 case LWPNSCALE:
6663 if ( get_qr(qr_OLDSPRITEDRAWS) )
6664 {
6665 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
6666 "lweapon->Scale");
6667 ret = -1; break;
6668 }
6669 if(0!=(s=checkLWpn(ri->lwpn,"Scale")))
6670 ret=((int32_t)((weapon*)(s))->scale)*100.0;
6671
6672 break;
6673
6674 case LWPNX:
6675
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 700149 times.
713905 if(0!=(s=checkLWpn(ri->lwpn,"X")))
6676 {
6677
2/2
✓ Branch 0 taken 153140 times.
✓ Branch 1 taken 547009 times.
700149 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6678 {
6679 153140 ret=(((weapon*)(s))->x).getZLong();
6680 153140 }
6681 else
6682 547009 ret=((int32_t)((weapon*)(s))->x)*10000;
6683 700149 }
6684
6685 713905 break;
6686
6687 case SPRITEMAXLWPN:
6688 {
6689 //No bounds check, as this is a universal function and works from NULL pointers!
6690 ret = Lwpns.getMax() * 10000;
6691 break;
6692 }
6693
6694 case LWPNY:
6695
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 695675 times.
709431 if(0!=(s=checkLWpn(ri->lwpn,"Y")))
6696 {
6697
2/2
✓ Branch 0 taken 153140 times.
✓ Branch 1 taken 542535 times.
695675 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6698 {
6699 153140 ret=(((weapon*)(s))->y).getZLong();
6700 153140 }
6701 else
6702 542535 ret=((int32_t)((weapon*)(s))->y)*10000;
6703 695675 }
6704 709431 break;
6705
6706 case LWPNZ:
6707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55748 times.
55748 if(0!=(s=checkLWpn(ri->lwpn,"Z")))
6708 {
6709
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 55746 times.
55748 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6710 {
6711 2 ret=(((weapon*)(s))->z).getZLong();
6712 2 }
6713 else
6714 55746 ret=((int32_t)((weapon*)(s))->z)*10000;
6715 55748 }
6716
6717 55748 break;
6718
6719 case LWPNJUMP:
6720 if(0!=(s=checkLWpn(ri->lwpn,"Jump")))
6721 {
6722 ret = ((weapon*)(s))->fall.getZLong() / -100;
6723 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
6724 }
6725
6726 break;
6727
6728 case LWPNFAKEJUMP:
6729 if(0!=(s=checkLWpn(ri->lwpn,"FakeJump")))
6730 {
6731 ret = ((weapon*)(s))->fakefall.getZLong() / -100;
6732 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
6733 }
6734
6735 break;
6736
6737 case LWPNDIR:
6738
1/2
✓ Branch 0 taken 67683 times.
✗ Branch 1 not taken.
67683 if(0!=(s=checkLWpn(ri->lwpn,"Dir")))
6739 67683 ret=((weapon*)(s))->dir*10000;
6740
6741 67683 break;
6742
6743 case LWPNGRAVITY:
6744 if(0!=(s=checkLWpn(ri->lwpn,"Gravity")))
6745 ret= (((weapon*)(s))->moveflags & FLAG_OBEYS_GRAV) ? 10000 : 0;
6746
6747 break;
6748
6749 case LWPNSTEP:
6750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1329 times.
1329 if(0!=(s=checkLWpn(ri->lwpn,"Step")))
6751 {
6752
3/4
✓ Branch 0 taken 1134 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 1134 times.
✗ Branch 3 not taken.
1329 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
6753 {
6754 1329 ret=((weapon*)s)->step.getZLong() * 100;
6755 1329 }
6756 //old, buggy code replication, round two: Go! -Z
6757 //else ret = ( ( ( ((weapon*)s)->step ) * 100.0 ).getZLong() );
6758
6759 //else
6760 //{
6761 //old, buggy code replication, round THREE: Go! -Z
6762 // double tmp = ( ((weapon*)s)->step.getFloat() ) * 1000000.0;
6763 // ret = (int32_t)tmp;
6764 //}
6765
6766 //old, buggy code replication, round FOUR: Go! -Z
6767 else ret = (int32_t)((float)((weapon*)s)->step * 1000000.0);
6768 1329 }
6769 1329 break;
6770
6771 case LWPNANGLE:
6772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(0!=(s=checkLWpn(ri->lwpn,"Angle")))
6773 2 ret=(int32_t)(((weapon*)(s))->angle*10000);
6774
6775 2 break;
6776
6777 case LWPNDEGANGLE:
6778 if(0!=(s=checkLWpn(ri->lwpn,"DegAngle")))
6779 {
6780 ret=(int32_t)(((weapon*)(s))->angle*(180.0 / PI)*10000);
6781 }
6782
6783 break;
6784
6785 case LWPNVX:
6786 if(0!=(s=checkLWpn(ri->lwpn,"Vx")))
6787 {
6788 if (((weapon*)(s))->angular)
6789 ret = int32_t(zc::math::Cos(((weapon*)s)->angle)*10000.0*((weapon*)s)->step);
6790 else
6791 {
6792 switch(NORMAL_DIR(((weapon*)(s))->dir))
6793 {
6794 case l_up:
6795 case l_down:
6796 case left:
6797 ret = int32_t(-10000.0*((weapon*)s)->step);
6798 break;
6799
6800 case r_down:
6801 case r_up:
6802 case right:
6803 ret = int32_t(10000.0*((weapon*)s)->step);
6804 break;
6805
6806 default:
6807 ret = 0;
6808 break;
6809 }
6810 }
6811 }
6812
6813 break;
6814
6815 case LWPNVY:
6816 if(0!=(s=checkLWpn(ri->lwpn,"Vy")))
6817 {
6818 if (((weapon*)(s))->angular)
6819 ret = int32_t(zc::math::Sin(((weapon*)s)->angle)*10000.0*((weapon*)s)->step);
6820 else
6821 {
6822 switch(NORMAL_DIR(((weapon*)(s))->dir))
6823 {
6824 case l_up:
6825 case r_up:
6826 case up:
6827 ret = int32_t(-10000.0*((weapon*)s)->step);
6828 break;
6829 case l_down:
6830 case r_down:
6831 case down:
6832 ret = int32_t(10000.0*((weapon*)s)->step);
6833 break;
6834
6835 default:
6836 ret = 0;
6837 break;
6838 }
6839 }
6840 }
6841
6842 break;
6843
6844 case LWPNANGULAR:
6845 if(0!=(s=checkLWpn(ri->lwpn,"Angular")))
6846 ret=((weapon*)(s))->angular*10000;
6847
6848 break;
6849
6850 case LWPNAUTOROTATE:
6851 if(0!=(s=checkLWpn(ri->lwpn,"AutoRotate")))
6852 ret=((weapon*)(s))->autorotate*10000;
6853
6854 break;
6855
6856 case LWPNBEHIND:
6857 if(0!=(s=checkLWpn(ri->lwpn,"Behind")))
6858 ret=((weapon*)(s))->behind*10000;
6859
6860 break;
6861
6862 case LWPNDRAWTYPE:
6863 if(0!=(s=checkLWpn(ri->lwpn,"DrawStyle")))
6864 ret=((weapon*)(s))->drawstyle*10000;
6865
6866 break;
6867
6868 case LWPNPOWER:
6869
2/2
✓ Branch 0 taken 85829 times.
✓ Branch 1 taken 1 times.
85830 if(0!=(s=checkLWpn(ri->lwpn,"Damage")))
6870 85829 ret=((weapon*)(s))->power*10000;
6871
6872 85830 break;
6873 /*
6874 case LWPNRANGE:
6875 if(0!=(s=checkLWpn(ri->lwpn,"Range")))
6876 ret=((weapon*)(s))->scriptrange*10000;
6877
6878 break;
6879 */
6880 case LWPNDEAD:
6881
1/2
✓ Branch 0 taken 1122 times.
✗ Branch 1 not taken.
1122 if(0!=(s=checkLWpn(ri->lwpn,"DeadState")))
6882 1122 ret=((weapon*)(s))->dead*10000;
6883
6884 1122 break;
6885
6886 case LWPNID:
6887
2/2
✓ Branch 0 taken 3771488 times.
✓ Branch 1 taken 13757 times.
3785245 if(0!=(s=checkLWpn(ri->lwpn,"ID")))
6888 3771488 ret=((weapon*)(s))->id*10000;
6889
6890 3785245 break;
6891
6892 case LWPNTILE:
6893
1/2
✓ Branch 0 taken 49772 times.
✗ Branch 1 not taken.
49772 if(0!=(s=checkLWpn(ri->lwpn,"Tile")))
6894 49772 ret=((weapon*)(s))->tile*10000;
6895
6896 49772 break;
6897
6898 case LWPNSCRIPTTILE:
6899 if(0!=(s=checkLWpn(ri->lwpn,"ScriptTile")))
6900 ret=((weapon*)(s))->scripttile*10000;
6901
6902 break;
6903
6904 case LWPNSCRIPTFLIP:
6905 if(0!=(s=checkLWpn(ri->lwpn,"ScriptFlip")))
6906 ret=((weapon*)(s))->scriptflip*10000;
6907
6908 break;
6909
6910 case LWPNCSET:
6911
1/2
✓ Branch 0 taken 49794 times.
✗ Branch 1 not taken.
49794 if(0!=(s=checkLWpn(ri->lwpn,"CSet")))
6912 49794 ret=((weapon*)(s))->cs*10000;
6913
6914 49794 break;
6915
6916 case LWPNFLASHCSET:
6917 if(0!=(s=checkLWpn(ri->lwpn,"FlashCSet")))
6918 ret=(((weapon*)(s))->o_cset>>4)*10000;
6919
6920 break;
6921
6922 case LWPNFRAMES:
6923
1/2
✓ Branch 0 taken 3289 times.
✗ Branch 1 not taken.
3289 if(0!=(s=checkLWpn(ri->lwpn,"NumFrames")))
6924 3289 ret=((weapon*)(s))->frames*10000;
6925
6926 3289 break;
6927
6928 case LWPNFRAME:
6929 if(0!=(s=checkLWpn(ri->lwpn,"Frame")))
6930 ret=((weapon*)(s))->aframe*10000;
6931
6932 break;
6933
6934 case LWPNASPEED:
6935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3289 times.
3289 if(0!=(s=checkLWpn(ri->lwpn,"ASpeed")))
6936 3289 ret=((weapon*)(s))->o_speed*10000;
6937
6938 3289 break;
6939
6940 case LWPNFLASH:
6941 if(0!=(s=checkLWpn(ri->lwpn,"Flash")))
6942 ret=((weapon*)(s))->flash*10000;
6943
6944 break;
6945
6946 case LWPNFLIP:
6947 if(0!=(s=checkLWpn(ri->lwpn,"Flip")))
6948 ret=((weapon*)(s))->flip*10000;
6949
6950 break;
6951
6952 case LWPNCOUNT:
6953 1094820 ret=Lwpns.Count()*10000;
6954 1094820 break;
6955
6956 case LWPNEXTEND:
6957 if(0!=(s=checkLWpn(ri->lwpn,"Extend")))
6958 ret=((weapon*)(s))->extend*10000;
6959
6960 break;
6961
6962 case LWPNOTILE:
6963
1/2
✓ Branch 0 taken 830567 times.
✗ Branch 1 not taken.
830567 if(0!=(s=checkLWpn(ri->lwpn,"OriginalTile")))
6964 830567 ret=((weapon*)(s))->o_tile*10000;
6965
6966 830567 break;
6967
6968 case LWPNOCSET:
6969 if(0!=(s=checkLWpn(ri->lwpn,"OriginalCSet")))
6970 ret=(((weapon*)(s))->o_cset&15)*10000;
6971
6972 break;
6973
6974 case LWPNHXOFS:
6975
2/2
✓ Branch 0 taken 121386 times.
✓ Branch 1 taken 13756 times.
135142 if(0!=(s=checkLWpn(ri->lwpn,"HitXOffset")))
6976 121386 ret=(((weapon*)(s))->hxofs)*10000;
6977
6978 135142 break;
6979
6980 case LWPNHYOFS:
6981
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 118638 times.
132394 if(0!=(s=checkLWpn(ri->lwpn,"HitYOffset")))
6982 118638 ret=(((weapon*)(s))->hyofs)*10000;
6983
6984 132394 break;
6985
6986 case LWPNXOFS:
6987 if(0!=(s=checkLWpn(ri->lwpn,"DrawXOffset")))
6988 ret=((int32_t)(((weapon*)(s))->xofs))*10000;
6989
6990 break;
6991
6992 case LWPNYOFS:
6993 if(0!=(s=checkLWpn(ri->lwpn,"DrawYOffset")))
6994 ret=((int32_t)(((weapon*)(s))->yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)))*10000;
6995
6996 break;
6997
6998 case LWPNSHADOWXOFS:
6999 if(0!=(s=checkLWpn(ri->lwpn,"ShadowXOffset")))
7000 ret=((int32_t)(((weapon*)(s))->shadowxofs))*10000;
7001
7002 break;
7003
7004 case LWPNSHADOWYOFS:
7005 if(0!=(s=checkLWpn(ri->lwpn,"ShadowYOffset")))
7006 ret=((int32_t)(((weapon*)(s))->shadowyofs))*10000;
7007
7008 break;
7009
7010 case LWPNTOTALDYOFFS:
7011 if(0!=(s=checkLWpn(ri->lwpn,"TotalDYOffset")))
7012 ret = ((int32_t)(((weapon*)(s))->yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset))
7013 + ((((weapon*)(s))->switch_hooked && Hero.switchhookstyle == swRISE)
7014 ? -(8-(abs(Hero.switchhookclk-32)/4)) : 0)) * 10000;
7015 break;
7016
7017 case LWPNZOFS:
7018 if(0!=(s=checkLWpn(ri->lwpn,"DrawZOffset")))
7019 ret=((int32_t)(((weapon*)(s))->zofs))*10000;
7020
7021 break;
7022
7023 case LWPNHXSZ:
7024
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 119380 times.
133136 if(0!=(s=checkLWpn(ri->lwpn,"HitWidth")))
7025 119380 ret=(((weapon*)(s))->hit_width)*10000;
7026
7027 133136 break;
7028
7029 case LWPNHYSZ:
7030
2/2
✓ Branch 0 taken 121335 times.
✓ Branch 1 taken 13756 times.
135091 if(0!=(s=checkLWpn(ri->lwpn,"HitHeight")))
7031 121335 ret=(((weapon*)(s))->hit_height)*10000;
7032
7033 135091 break;
7034
7035 case LWPNHZSZ:
7036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27874 times.
27874 if(0!=(s=checkLWpn(ri->lwpn,"HitZHeight")))
7037 27874 ret=(((weapon*)(s))->hzsz)*10000;
7038
7039 27874 break;
7040
7041 case LWPNTXSZ:
7042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25249 times.
25249 if(0!=(s=checkLWpn(ri->lwpn,"TileWidth")))
7043 25249 ret=(((weapon*)(s))->txsz)*10000;
7044
7045 25249 break;
7046
7047 case LWPNTYSZ:
7048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25249 times.
25249 if(0!=(s=checkLWpn(ri->lwpn,"TileHeight")))
7049 25249 ret=(((weapon*)(s))->tysz)*10000;
7050
7051 25249 break;
7052
7053 case LWPNMISCD:
7054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1553638 times.
1553638 if(0!=(s=checkLWpn(ri->lwpn,"Misc")))
7055 {
7056 1553638 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
7057 1553638 ret=(((weapon*)(s))->miscellaneous[a]);
7058 1553638 }
7059
7060 1553638 break;
7061
7062 case LWPNCOLLDET:
7063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4320 times.
4320 if(0!=(s=checkLWpn(ri->lwpn,"CollDetection")))
7064 4320 ret=(((weapon*)(s))->scriptcoldet)*10000;
7065
7066 4320 break;
7067
7068 case LWPNENGINEANIMATE:
7069 if(0!=(s=checkLWpn(ri->lwpn,"Animation")))
7070 ret=(((weapon*)(s))->do_animation)*10000;
7071
7072 break;
7073
7074 case LWPNPARENT:
7075 if(0!=(s=checkLWpn(ri->lwpn,"Parent")))
7076 ret=(((weapon*)(s))->parentitem)*10000;
7077
7078 break;
7079
7080 case LWPNLEVEL:
7081 if(0!=(s=checkLWpn(ri->lwpn,"Level")))
7082 ret=(((weapon*)(s))->type)*10000;
7083
7084 break;
7085
7086 case LWPNSCRIPT:
7087 if(0!=(s=checkLWpn(ri->lwpn,"Script")))
7088 ret=(((weapon*)(s))->weaponscript)*10000;
7089
7090 break;
7091
7092 case LWPNUSEWEAPON:
7093
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(0!=(s=checkLWpn(ri->lwpn,"Weapon")))
7094 179 ret=(((weapon*)(s))->useweapon)*10000;
7095
7096 179 break;
7097
7098 case LWPNUSEDEFENCE:
7099 if(0!=(s=checkLWpn(ri->lwpn,"Defense")))
7100 ret=(((weapon*)(s))->usedefence)*10000;
7101
7102 break;
7103
7104 case LWPNINITD:
7105 {
7106 180 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
7107
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(0!=(s=checkLWpn(ri->lwpn,"InitD[]")))
7108 {
7109 180 ret=(((weapon*)(s))->weap_initd[a]);
7110 180 }
7111 180 break;
7112 }
7113
7114 case LWEAPONSCRIPTUID:
7115 if(0!=(s=checkLWpn(ri->lwpn,"ScriptUID")))
7116 ret=(((weapon*)(s))->script_UID); //literal, not *10000
7117
7118 break;
7119
7120 case LWPNROTATION:
7121 if ( get_qr(qr_OLDSPRITEDRAWS) )
7122 {
7123 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
7124 "lweapon->Rotation");
7125 ret = -1; break;
7126 }
7127 if(0!=(s=checkLWpn(ri->lwpn,"Rotation")))
7128 ret=((weapon*)(s))->rotation*10000;
7129
7130 break;
7131
7132 case LWPNFALLCLK:
7133 if(0!=(s=checkLWpn(ri->lwpn,"Falling")))
7134 {
7135 ret = ((weapon*)(s))->fallclk * 10000;
7136 }
7137 break;
7138
7139 case LWPNFALLCMB:
7140 if(0!=(s=checkLWpn(ri->lwpn,"FallCombo")))
7141 {
7142 ret = ((weapon*)(s))->fallCombo * 10000;
7143 }
7144 break;
7145
7146 case LWPNDROWNCLK:
7147 if(0!=(s=checkLWpn(ri->lwpn,"Drowning")))
7148 {
7149 ret = ((weapon*)(s))->drownclk * 10000;
7150 }
7151 break;
7152
7153 case LWPNDROWNCMB:
7154 if(0!=(s=checkLWpn(ri->lwpn,"DrownCombo")))
7155 {
7156 ret = ((weapon*)(s))->drownCombo * 10000;
7157 }
7158 break;
7159
7160 case LWPNFAKEZ:
7161 if(0!=(s=checkLWpn(ri->lwpn,"FakeZ")))
7162 {
7163 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
7164 {
7165 ret=(((weapon*)(s))->fakez).getZLong();
7166 }
7167 else
7168 ret=((int32_t)((weapon*)(s))->fakez)*10000;
7169 }
7170 break;
7171
7172 case LWPNMOVEFLAGS:
7173 {
7174 if(0!=(s=checkLWpn(ri->lwpn,"MoveFlags[]")))
7175 {
7176 int32_t indx = ri->d[rINDEX]/10000;
7177 if(BC::checkBounds(indx, 0, 10, "lweapon->MoveFlags[]") != SH::_NoError)
7178 ret = 0; //false
7179 else
7180 {
7181 //All bits, in order, of a single byte; just use bitwise
7182 ret = (((weapon*)(s))->moveflags & (1<<indx)) ? 10000 : 0;
7183 }
7184 }
7185 break;
7186 }
7187 case LWPNFLAGS:
7188 {
7189 if(0!=(s=checkLWpn(ri->lwpn,"Flags[]")))
7190 {
7191 int32_t indx = ri->d[rINDEX]/10000;
7192 if(BC::checkBounds(indx, 0, WFLAG_MAX, "lweapon->Flags[]") != SH::_NoError)
7193 ret = 0; //false
7194 else
7195 {
7196 //All bits, in order, of a single byte; just use bitwise
7197 ret = (((weapon*)(s))->misc_wflags & (1<<indx)) ? 10000 : 0;
7198 }
7199 }
7200 break;
7201 }
7202
7203 case LWPNGLOWRAD:
7204 if(0!=(s=checkLWpn(ri->lwpn,"LightRadius")))
7205 {
7206 ret = ((weapon*)(s))->glowRad * 10000;
7207 }
7208 break;
7209
7210 case LWPNGLOWSHP:
7211 if(0!=(s=checkLWpn(ri->lwpn,"LightShape")))
7212 {
7213 ret = ((weapon*)(s))->glowShape * 10000;
7214 }
7215 break;
7216
7217 case LWPNUNBL:
7218 if(0!=(s=checkLWpn(ri->lwpn,"Unblockable")))
7219 {
7220 ret = ((weapon*)(s))->unblockable * 10000;
7221 }
7222 break;
7223
7224 case LWPNSHADOWSPR:
7225 if(0!=(s=checkLWpn(ri->lwpn,"ShadowSprite")))
7226 {
7227 ret = ((weapon*)(s))->spr_shadow * 10000;
7228 }
7229 break;
7230 case LWSWHOOKED:
7231 if(0!=(s=checkLWpn(ri->lwpn,"SwitchHooked")))
7232 {
7233 ret = s->switch_hooked ? 10000 : 0;
7234 }
7235 break;
7236 case LWPNTIMEOUT:
7237 if(0!=(s=checkLWpn(ri->lwpn,"Timeout")))
7238 {
7239 ret = ((weapon*)(s))->weap_timeout * 10000;
7240 }
7241 break;
7242 case LWPNDEATHITEM:
7243 if(0!=(s=checkLWpn(ri->lwpn,"DeathItem")))
7244 {
7245 ret = ((weapon*)(s))->death_spawnitem * 10000;
7246 }
7247 break;
7248 case LWPNDEATHDROPSET:
7249 if(0!=(s=checkLWpn(ri->lwpn,"DeathDropset")))
7250 {
7251 ret = ((weapon*)(s))->death_spawndropset * 10000;
7252 }
7253 break;
7254 case LWPNDEATHIPICKUP:
7255 if(0!=(s=checkLWpn(ri->lwpn,"DeathItemPFlags")))
7256 {
7257 ret = ((weapon*)(s))->death_item_pflags * 10000;
7258 }
7259 break;
7260 case LWPNDEATHSPRITE:
7261 if(0!=(s=checkLWpn(ri->lwpn,"DeathSprite")))
7262 {
7263 ret = ((weapon*)(s))->death_sprite * 10000;
7264 }
7265 break;
7266 case LWPNDEATHSFX:
7267 if(0!=(s=checkLWpn(ri->lwpn,"DeathSFX")))
7268 {
7269 ret = ((weapon*)(s))->death_sfx * 10000;
7270 }
7271 break;
7272 case LWPNLIFTLEVEL:
7273 if(0!=(s=checkLWpn(ri->lwpn,"LiftLevel")))
7274 {
7275 ret = ((weapon*)(s))->lift_level * 10000;
7276 }
7277 break;
7278 case LWPNLIFTTIME:
7279 if(0!=(s=checkLWpn(ri->lwpn,"LiftTime")))
7280 {
7281 ret = ((weapon*)(s))->lift_time * 10000;
7282 }
7283 break;
7284 case LWPNLIFTHEIGHT:
7285 if(0!=(s=checkLWpn(ri->lwpn,"LiftHeight")))
7286 {
7287 ret = ((weapon*)(s))->lift_height.getZLong();
7288 }
7289 break;
7290
7291 ///----------------------------------------------------------------------------------------------------//
7292 //EWeapon Variables
7293 case EWPNSCALE:
7294 if ( get_qr(qr_OLDSPRITEDRAWS) )
7295 {
7296 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
7297 "eweapon->Scale");
7298 ret = -1; break;
7299 }
7300 if(0!=(s=checkEWpn(ri->ewpn, "Scale")))
7301 ret=((int32_t)((weapon*)(s))->scale)*100.0;
7302
7303 break;
7304
7305 case EWPNX:
7306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1267145 times.
1267145 if(0!=(s=checkEWpn(ri->ewpn, "X")))
7307 {
7308
2/2
✓ Branch 0 taken 148798 times.
✓ Branch 1 taken 1118347 times.
1267145 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
7309 {
7310 148798 ret=(((weapon*)(s))->x).getZLong();
7311 148798 }
7312 else
7313 1118347 ret=((int32_t)((weapon*)(s))->x)*10000;
7314 1267145 }
7315 1267145 break;
7316
7317 case SPRITEMAXEWPN:
7318 {
7319 //No bounds check, as this is a universal function and works from NULL pointers!
7320 ret = Ewpns.getMax() * 10000;
7321 break;
7322 }
7323
7324 case EWPNY:
7325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1266708 times.
1266708 if(0!=(s=checkEWpn(ri->ewpn, "Y")))
7326 {
7327
2/2
✓ Branch 0 taken 148686 times.
✓ Branch 1 taken 1118022 times.
1266708 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
7328 {
7329 148686 ret=(((weapon*)(s))->y).getZLong();
7330 148686 }
7331 else
7332 1118022 ret=((int32_t)((weapon*)(s))->y)*10000;
7333 1266708 }
7334 1266708 break;
7335
7336 case EWPNZ:
7337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63485 times.
63485 if(0!=(s=checkEWpn(ri->ewpn, "Z")))
7338 {
7339
2/2
✓ Branch 0 taken 607 times.
✓ Branch 1 taken 62878 times.
63485 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
7340 {
7341 607 ret=(((weapon*)(s))->z).getZLong();
7342 607 }
7343 else
7344 62878 ret=((int32_t)((weapon*)(s))->z)*10000;
7345 63485 }
7346 63485 break;
7347
7348 case EWPNJUMP:
7349 if(0!=(s=checkEWpn(ri->ewpn, "Jump")))
7350 {
7351 ret = ((weapon*)(s))->fall.getZLong() / -100;
7352 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
7353 }
7354
7355 break;
7356
7357 case EWPNFAKEJUMP:
7358 if(0!=(s=checkEWpn(ri->ewpn, "FakeJump")))
7359 {
7360 ret = ((weapon*)(s))->fakefall.getZLong() / -100;
7361 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
7362 }
7363
7364 break;
7365
7366 case EWPNDIR:
7367
1/2
✓ Branch 0 taken 22679 times.
✗ Branch 1 not taken.
22679 if(0!=(s=checkEWpn(ri->ewpn, "Dir")))
7368 22679 ret=((weapon*)(s))->dir*10000;
7369
7370 22679 break;
7371
7372 case EWPNLEVEL:
7373 if(0!=(s=checkEWpn(ri->ewpn, "Level")))
7374 ret=((weapon*)(s))->type*10000;
7375
7376 break;
7377
7378 case EWPNGRAVITY:
7379 if(0!=(s=checkEWpn(ri->ewpn, "Gravity")))
7380 ret=((((weapon*)(s))->moveflags & FLAG_OBEYS_GRAV) ? 10000 : 0);
7381
7382 break;
7383
7384 case EWPNSTEP:
7385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 362690 times.
362690 if(0!=(s=checkEWpn(ri->ewpn, "Step")))
7386 {
7387
3/4
✓ Branch 0 taken 362528 times.
✓ Branch 1 taken 162 times.
✓ Branch 2 taken 362528 times.
✗ Branch 3 not taken.
362690 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
7388 {
7389 362690 ret=((weapon*)s)->step.getZLong() * 100;
7390 362690 }
7391 //old, buggy code replication, round two: Go! -Z
7392 //else ret = ( ( ( ((weapon*)s)->step ) * 100.0 ).getZLong() );
7393 //old, buggy code replication, round FOUR: Go! -Z
7394 else ret = (int32_t)((float)((weapon*)s)->step * 1000000.0);
7395 362690 }
7396 //else
7397 //{
7398 //old, buggy code replication, round THREE: Go! -Z
7399 // double tmp = ( ((weapon*)s)->step.getFloat() ) * 1000000.0;
7400 // ret = int32_t(tmp);
7401 //}
7402 362690 break;
7403
7404 case EWPNANGLE:
7405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 373525 times.
373525 if(0!=(s=checkEWpn(ri->ewpn,"Angle")))
7406 373525 ret=(int32_t)(((weapon*)(s))->angle*10000);
7407
7408 373525 break;
7409
7410 case EWPNDEGANGLE:
7411 if(0!=(s=checkEWpn(ri->ewpn,"DegAngle")))
7412 {
7413 ret=(int32_t)(((weapon*)(s))->angle*(180.0 / PI)*10000);
7414 }
7415
7416 break;
7417
7418 case EWPNVX:
7419 if(0!=(s=checkEWpn(ri->ewpn,"Vx")))
7420 {
7421 if (((weapon*)(s))->angular)
7422 ret = int32_t(zc::math::Cos(((weapon*)s)->angle)*10000.0*((weapon*)s)->step);
7423 else
7424 {
7425 switch(NORMAL_DIR(((weapon*)(s))->dir))
7426 {
7427 case l_up:
7428 case l_down:
7429 case left:
7430 ret = int32_t(-10000.0*((weapon*)s)->step);
7431 break;
7432 case r_up:
7433 case r_down:
7434 case right:
7435 ret = int32_t(10000.0*((weapon*)s)->step);
7436 break;
7437
7438 default:
7439 ret = 0;
7440 break;
7441 }
7442 }
7443 }
7444
7445 break;
7446
7447 case EWPNVY:
7448 if(0!=(s=checkEWpn(ri->ewpn,"Vy")))
7449 {
7450 if (((weapon*)(s))->angular)
7451 ret = int32_t(zc::math::Sin(((weapon*)s)->angle)*10000.0*((weapon*)s)->step);
7452 else
7453 {
7454 switch(NORMAL_DIR(((weapon*)(s))->dir))
7455 {
7456 case l_up:
7457 case r_up:
7458 case up:
7459 ret = int32_t(-10000.0*((weapon*)s)->step);
7460 break;
7461 case l_down:
7462 case r_down:
7463 case down:
7464 ret = int32_t(10000.0*((weapon*)s)->step);
7465 break;
7466
7467 default:
7468 ret = 0;
7469 break;
7470 }
7471 }
7472 }
7473
7474 break;
7475
7476
7477 case EWPNANGULAR:
7478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68688 times.
68688 if(0!=(s=checkEWpn(ri->ewpn,"Angular")))
7479 68688 ret=((weapon*)(s))->angular*10000;
7480
7481 68688 break;
7482
7483 case EWPNAUTOROTATE:
7484 if(0!=(s=checkEWpn(ri->ewpn,"AutoRotate")))
7485 ret=((weapon*)(s))->autorotate*10000;
7486
7487 break;
7488
7489 case EWPNBEHIND:
7490 if(0!=(s=checkEWpn(ri->ewpn,"Behind")))
7491 ret=((weapon*)(s))->behind*10000;
7492
7493 break;
7494
7495 case EWPNDRAWTYPE:
7496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46359 times.
46359 if(0!=(s=checkEWpn(ri->ewpn,"DrawStyle")))
7497 46359 ret=((weapon*)(s))->drawstyle*10000;
7498
7499 46359 break;
7500
7501 case EWPNPOWER:
7502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90188 times.
90188 if(0!=(s=checkEWpn(ri->ewpn,"Damage")))
7503 90188 ret=((weapon*)(s))->power*10000;
7504
7505 90188 break;
7506
7507 case EWPNDEAD:
7508
1/2
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
154 if(0!=(s=checkEWpn(ri->ewpn,"DeadState")))
7509 154 ret=((weapon*)(s))->dead*10000;
7510
7511 154 break;
7512
7513 case EWPNID:
7514
1/2
✓ Branch 0 taken 2150394 times.
✗ Branch 1 not taken.
2150394 if(0!=(s=checkEWpn(ri->ewpn,"ID")))
7515 2150394 ret=((weapon*)(s))->id*10000;
7516
7517 2150394 break;
7518
7519 case EWPNTILE:
7520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106032 times.
106032 if(0!=(s=checkEWpn(ri->ewpn,"Tile")))
7521 106032 ret=((weapon*)(s))->tile*10000;
7522
7523 106032 break;
7524
7525 case EWPNSCRIPTTILE:
7526 if(0!=(s=checkEWpn(ri->ewpn,"ScriptTile")))
7527 ret=((weapon*)(s))->scripttile*10000;
7528
7529 break;
7530
7531 case EWPNSCRIPTFLIP:
7532 if(0!=(s=checkEWpn(ri->ewpn,"ScriptFlip")))
7533 ret=((weapon*)(s))->scriptflip*10000;
7534
7535 break;
7536
7537 case EWPNCSET:
7538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24909 times.
24909 if(0!=(s=checkEWpn(ri->ewpn,"CSet")))
7539 24909 ret=((weapon*)(s))->cs*10000;
7540
7541 24909 break;
7542
7543 case EWPNFLASHCSET:
7544 if(0!=(s=checkEWpn(ri->ewpn,"FlashCSet")))
7545 ret=(((weapon*)(s))->o_cset>>4)*10000;
7546
7547 break;
7548
7549 case EWPNFRAMES:
7550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(0!=(s=checkEWpn(ri->ewpn,"NumFrames")))
7551 70 ret=((weapon*)(s))->frames*10000;
7552
7553 70 break;
7554
7555 case EWPNFRAME:
7556 if(0!=(s=checkEWpn(ri->ewpn,"Frame")))
7557 ret=((weapon*)(s))->aframe*10000;
7558
7559 break;
7560
7561 case EWPNASPEED:
7562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(0!=(s=checkEWpn(ri->ewpn,"ASpeed")))
7563 70 ret=((weapon*)(s))->o_speed*10000;
7564
7565 70 break;
7566
7567 case EWPNFLASH:
7568 if(0!=(s=checkEWpn(ri->ewpn,"Flash")))
7569 ret=((weapon*)(s))->flash*10000;
7570
7571 break;
7572
7573 case EWPNFLIP:
7574 if(0!=(s=checkEWpn(ri->ewpn,"Flip")))
7575 ret=((weapon*)(s))->flip*10000;
7576
7577 break;
7578
7579 case EWPNROTATION:
7580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 218 times.
218 if ( get_qr(qr_OLDSPRITEDRAWS) )
7581 {
7582 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
7583 "eweapon->Rotation");
7584 break;
7585 }
7586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 218 times.
218 if(0!=(s=checkEWpn(ri->ewpn,"Rotation")))
7587 218 ret=((weapon*)(s))->rotation*10000;
7588
7589 218 break;
7590
7591 case EWPNCOUNT:
7592 1911946 ret=Ewpns.Count()*10000;
7593 1911946 break;
7594
7595 case EWPNEXTEND:
7596 if(0!=(s=checkEWpn(ri->ewpn,"Extend")))
7597 ret=((weapon*)(s))->extend*10000;
7598
7599 break;
7600
7601 case EWPNOTILE:
7602
1/2
✓ Branch 0 taken 2925 times.
✗ Branch 1 not taken.
2925 if(0!=(s=checkEWpn(ri->ewpn,"OriginalTile")))
7603 2925 ret=((weapon*)(s))->o_tile*10000;
7604
7605 2925 break;
7606
7607 case EWPNOCSET:
7608 if(0!=(s=checkEWpn(ri->ewpn,"OriginalCSet")))
7609 ret=(((weapon*)(s))->o_cset&15)*10000;
7610
7611 break;
7612
7613 case EWPNHXOFS:
7614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65540 times.
65540 if(0!=(s=checkEWpn(ri->ewpn,"HitXOffset")))
7615 65540 ret=(((weapon*)(s))->hxofs)*10000;
7616
7617 65540 break;
7618
7619 case EWPNHYOFS:
7620
1/2
✓ Branch 0 taken 65540 times.
✗ Branch 1 not taken.
65540 if(0!=(s=checkEWpn(ri->ewpn,"HitYOffset")))
7621 65540 ret=(((weapon*)(s))->hyofs)*10000;
7622
7623 65540 break;
7624
7625 case EWPNXOFS:
7626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(0!=(s=checkEWpn(ri->ewpn,"DrawXOffset")))
7627 8 ret=((int32_t)(((weapon*)(s))->xofs))*10000;
7628
7629 8 break;
7630
7631 case EWPNYOFS:
7632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(0!=(s=checkEWpn(ri->ewpn,"DrawYOffset")))
7633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=((int32_t)(((weapon*)(s))->yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)))*10000;
7634
7635 96 break;
7636
7637 case EWPNSHADOWXOFS:
7638 if(0!=(s=checkEWpn(ri->ewpn,"ShadowXOffset")))
7639 ret=((int32_t)(((weapon*)(s))->shadowxofs))*10000;
7640
7641 break;
7642
7643 case EWPNSHADOWYOFS:
7644 if(0!=(s=checkEWpn(ri->ewpn,"ShadowYOffset")))
7645 ret=((int32_t)(((weapon*)(s))->shadowyofs))*10000;
7646
7647 break;
7648 case EWPNTOTALDYOFFS:
7649 if(0!=(s=checkLWpn(ri->ewpn,"TotalDYOffset")))
7650 ret = ((int32_t)(((weapon*)(s))->yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset))
7651 + ((((weapon*)(s))->switch_hooked && Hero.switchhookstyle == swRISE)
7652 ? -(8-(abs(Hero.switchhookclk-32)/4)) : 0) * 10000);
7653 break;
7654
7655 case EWPNZOFS:
7656 if(0!=(s=checkEWpn(ri->ewpn,"DrawZOffset")))
7657 ret=((int32_t)(((weapon*)(s))->zofs))*10000;
7658
7659 break;
7660
7661 case EWPNHXSZ:
7662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62523 times.
62523 if(0!=(s=checkEWpn(ri->ewpn,"HitWidth")))
7663 62523 ret=(((weapon*)(s))->hit_width)*10000;
7664
7665 62523 break;
7666
7667 case EWPNHYSZ:
7668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62523 times.
62523 if(0!=(s=checkEWpn(ri->ewpn,"HitHeight")))
7669 62523 ret=(((weapon*)(s))->hit_height)*10000;
7670
7671 62523 break;
7672
7673 case EWPNHZSZ:
7674
1/2
✓ Branch 0 taken 12470 times.
✗ Branch 1 not taken.
12470 if(0!=(s=checkEWpn(ri->ewpn,"HitZHeight")))
7675 12470 ret=(((weapon*)(s))->hzsz)*10000;
7676
7677 12470 break;
7678
7679 case EWPNTXSZ:
7680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24497 times.
24497 if(0!=(s=checkEWpn(ri->ewpn,"TileWidth")))
7681 24497 ret=(((weapon*)(s))->txsz)*10000;
7682
7683 24497 break;
7684
7685 case EWPNTYSZ:
7686
1/2
✓ Branch 0 taken 24497 times.
✗ Branch 1 not taken.
24497 if(0!=(s=checkEWpn(ri->ewpn,"TileHeight")))
7687 24497 ret=(((weapon*)(s))->tysz)*10000;
7688
7689 24497 break;
7690
7691 case EWPNMISCD:
7692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13780500 times.
13780500 if(0!=(s=checkEWpn(ri->ewpn,"Misc")))
7693 {
7694 13780500 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
7695 13780500 ret=(((weapon*)(s))->miscellaneous[a]);
7696 13780500 }
7697
7698 13780500 break;
7699
7700 case EWPNCOLLDET:
7701 if(0!=(s=checkEWpn(ri->ewpn,"CollDetection")))
7702 ret=(((weapon*)(s))->scriptcoldet)*10000;
7703
7704 break;
7705
7706 case EWPNENGINEANIMATE:
7707 if(0!=(s=checkEWpn(ri->ewpn,"Animation")))
7708 ret=(((weapon*)(s))->do_animation)*10000;
7709
7710 break;
7711
7712 case EWPNPARENT:
7713 if(0!=(s=checkEWpn(ri->ewpn, "Parent")))
7714 ret= ((get_qr(qr_OLDEWPNPARENT)) ? (((weapon*)(s))->parentid)*10000 : (((weapon*)(s))->parentid));
7715
7716 break;
7717
7718 case EWEAPONSCRIPTUID:
7719 if(0!=(s=checkEWpn(ri->ewpn, "ScriptUID")))
7720 ret=(((weapon*)(s))->script_UID); //literal, not *10000
7721
7722 break;
7723
7724 case EWPNPARENTUID:
7725 if(0!=(s=checkEWpn(ri->ewpn, "ParentUID")))
7726 ret=(((weapon*)(s))->parent_script_UID); //literal, not *10000
7727
7728 break;
7729
7730 case EWPNSCRIPT:
7731 if(0!=(s=checkEWpn(ri->ewpn,"Script")))
7732 ret=(((weapon*)(s))->weaponscript)*10000;
7733
7734 break;
7735
7736 case EWPNINITD:
7737 {
7738 16680 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
7739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16680 times.
16680 if(0!=(s=checkEWpn(ri->ewpn,"InitD[]")))
7740 {
7741 16680 ret=(((weapon*)(s))->weap_initd[a]);
7742 16680 }
7743 16680 break;
7744 }
7745
7746 case EWPNFALLCLK:
7747 if(0!=(s=checkEWpn(ri->ewpn,"Falling")))
7748 {
7749 ret = ((weapon*)(s))->fallclk * 10000;
7750 }
7751 break;
7752
7753 case EWPNFALLCMB:
7754 if(0!=(s=checkEWpn(ri->ewpn,"FallCombo")))
7755 {
7756 ret = ((weapon*)(s))->fallCombo * 10000;
7757 }
7758 break;
7759
7760 case EWPNDROWNCLK:
7761 if(0!=(s=checkEWpn(ri->ewpn,"Drowning")))
7762 {
7763 ret = ((weapon*)(s))->drownclk * 10000;
7764 }
7765 break;
7766
7767 case EWPNDROWNCMB:
7768 if(0!=(s=checkEWpn(ri->ewpn,"DrownCombo")))
7769 {
7770 ret = ((weapon*)(s))->drownCombo * 10000;
7771 }
7772 break;
7773 case EWPNFAKEZ:
7774 if(0!=(s=checkEWpn(ri->ewpn, "FakeZ")))
7775 {
7776 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
7777 {
7778 ret=(((weapon*)(s))->fakez).getZLong();
7779 }
7780 else
7781 ret=((int32_t)((weapon*)(s))->fakez)*10000;
7782 }
7783 break;
7784
7785 case EWPNMOVEFLAGS:
7786 {
7787 if(0!=(s=checkEWpn(ri->ewpn,"MoveFlags[]")))
7788 {
7789 int32_t indx = ri->d[rINDEX]/10000;
7790 if(BC::checkBounds(indx, 0, 10, "eweapon->MoveFlags[]") != SH::_NoError)
7791 ret = 0; //false
7792 else
7793 {
7794 //All bits, in order, of a single byte; just use bitwise
7795 ret = (((weapon*)(s))->moveflags & (1<<indx)) ? 10000 : 0;
7796 }
7797 }
7798 break;
7799 }
7800 case EWPNFLAGS:
7801 {
7802 if(0!=(s=checkEWpn(ri->ewpn,"Flags[]")))
7803 {
7804 int32_t indx = ri->d[rINDEX]/10000;
7805 if(BC::checkBounds(indx, 0, WFLAG_MAX, "eweapon->Flags[]") != SH::_NoError)
7806 ret = 0; //false
7807 else
7808 {
7809 //All bits, in order, of a single byte; just use bitwise
7810 ret = (((weapon*)(s))->misc_wflags & (1<<indx)) ? 10000 : 0;
7811 }
7812 }
7813 break;
7814 }
7815
7816 case EWPNGLOWRAD:
7817 if(0!=(s=checkEWpn(ri->ewpn,"LightRadius")))
7818 {
7819 ret = ((weapon*)(s))->glowRad * 10000;
7820 }
7821 break;
7822
7823 case EWPNGLOWSHP:
7824 if(0!=(s=checkEWpn(ri->ewpn,"LightShape")))
7825 {
7826 ret = ((weapon*)(s))->glowShape * 10000;
7827 }
7828 break;
7829
7830 case EWPNUNBL:
7831 if(0!=(s=checkEWpn(ri->ewpn,"Unblockable")))
7832 {
7833 ret = ((weapon*)(s))->unblockable * 10000;
7834 }
7835 break;
7836
7837 case EWPNSHADOWSPR:
7838 if(0!=(s=checkEWpn(ri->ewpn,"ShadowSprite")))
7839 {
7840 ret = ((weapon*)(s))->spr_shadow * 10000;
7841 }
7842 break;
7843 case EWSWHOOKED:
7844 if(0!=(s=checkEWpn(ri->ewpn,"SwitchHooked")))
7845 {
7846 ret = s->switch_hooked ? 10000 : 0;
7847 }
7848 break;
7849 case EWPNTIMEOUT:
7850 if(0!=(s=checkEWpn(ri->ewpn,"Timeout")))
7851 {
7852 ret = ((weapon*)(s))->weap_timeout * 10000;
7853 }
7854 break;
7855 case EWPNDEATHITEM:
7856 if(0!=(s=checkEWpn(ri->ewpn,"DeathItem")))
7857 {
7858 ret = ((weapon*)(s))->death_spawnitem * 10000;
7859 }
7860 break;
7861 case EWPNDEATHDROPSET:
7862 if(0!=(s=checkEWpn(ri->ewpn,"DeathDropset")))
7863 {
7864 ret = ((weapon*)(s))->death_spawndropset * 10000;
7865 }
7866 break;
7867 case EWPNDEATHIPICKUP:
7868 if(0!=(s=checkEWpn(ri->ewpn,"DeathItemPFlags")))
7869 {
7870 ret = ((weapon*)(s))->death_item_pflags * 10000;
7871 }
7872 break;
7873 case EWPNDEATHSPRITE:
7874 if(0!=(s=checkEWpn(ri->ewpn,"DeathSprite")))
7875 {
7876 ret = ((weapon*)(s))->death_sprite * 10000;
7877 }
7878 break;
7879 case EWPNDEATHSFX:
7880 if(0!=(s=checkEWpn(ri->ewpn,"DeathSFX")))
7881 {
7882 ret = ((weapon*)(s))->death_sfx * 10000;
7883 }
7884 break;
7885 case EWPNLIFTLEVEL:
7886 if(0!=(s=checkEWpn(ri->ewpn,"LiftLevel")))
7887 {
7888 ret = ((weapon*)(s))->lift_level * 10000;
7889 }
7890 break;
7891 case EWPNLIFTTIME:
7892 if(0!=(s=checkEWpn(ri->ewpn,"LiftTime")))
7893 {
7894 ret = ((weapon*)(s))->lift_time * 10000;
7895 }
7896 break;
7897 case EWPNLIFTHEIGHT:
7898 if(0!=(s=checkEWpn(ri->ewpn,"LiftHeight")))
7899 {
7900 ret = ((weapon*)(s))->lift_height.getZLong();
7901 }
7902 break;
7903
7904 /*
7905 case LWEAPONSCRIPTUID:
7906 if(0!=(s=checkLWpn(ri->lwpn,"ScriptUID")))
7907 ret=(((weapon*)(s))->getScriptUID()); //literal, not *10000
7908
7909 break;
7910 case EWEAPONSCRIPTUID:
7911 if(0!=(s=checkLWpn(ri->ewpn,"ScriptUID")))
7912 ret=(((weapon*)(s))->getScriptUID()); //literal, not *10000
7913
7914 break;
7915 */
7916
7917 ///----------------------------------------------------------------------------------------------------//
7918 //Game Info
7919
7920
7921 case GAMEPLAYFIELDOFS:
7922 ret = playing_field_offset*10000;
7923 break;
7924
7925 case GETPIXEL:
7926 ret=FFCore.do_getpixel();
7927 break;
7928
7929
7930 case ZELDAVERSION:
7931 ret = ZC_VERSION; //Do *not* multiply by 10,000!
7932 break;
7933 case ZELDABUILD:
7934 ret = (int32_t)VERSION_BUILD*10000;
7935 break;
7936
7937 case ZSCRIPTVERSION:
7938 {
7939 ret = (FFCore.quest_format[vLastCompile]) * 10000;
7940 break;
7941 }
7942
7943 case ZELDABETATYPE:
7944 {
7945 ret = int32_t(ALPHA_STATE*10000);
7946 break;
7947 }
7948 case ZELDABETA:
7949 {
7950 ret = int32_t(ALPHA_VER*10000);
7951 if(ZC_IS_NIGHTLY) //Nightly 111/112 should return '111.5' not '112'
7952 ret -= 5000;
7953 break;
7954 }
7955 case GAMEDEATHS:
7956 ret=game->get_deaths()*10000;
7957 break;
7958
7959 case GAMECHEAT:
7960 ret=cheat*10000;
7961 break;
7962
7963 case GAMEMAXCHEAT:
7964 ret=maxcheat*10000;
7965 break;
7966
7967 case GAMETIME:
7968 2103 ret=game->get_time();
7969 2103 break;// Can't multiply by 10000 or the maximum result is too big
7970 case ACTIVESSSPEED:
7971 ret=Hero.subscr_speed*10000;
7972 break;// Can't multiply by 10000 or the maximum result is too big
7973
7974 case GAMETIMEVALID:
7975 2103 ret=game->get_timevalid()?10000:0;
7976 2103 break;
7977
7978 case GAMEHASPLAYED:
7979 ret=game->get_hasplayed()?10000:0;
7980 break;
7981
7982 case TYPINGMODE:
7983 ret=FFCore.kb_typing_mode?10000:0;
7984 break;
7985
7986 case SKIPCREDITS:
7987 ret=FFCore.skip_ending_credits?10000:0;
7988 break;
7989
7990 case SKIPF6:
7991 ret=get_qr(qr_NOCONTINUE)?10000:0;
7992 break;
7993
7994 case GAMESTANDALONE:
7995 17 ret=standalone_mode?10000:0;
7996 17 break;
7997
7998 case GAMEGUYCOUNT:
7999 {
8000 26 int32_t mi = (currmap*MAPSCRSNORMAL)+(ri->d[rINDEX]/10000);
8001 26 ret=game->guys[mi]*10000;
8002 }
8003 26 break;
8004
8005 case GAMECONTSCR:
8006 678 ret=game->get_continue_scrn()*10000;
8007 678 break;
8008
8009 case GAMECONTDMAP:
8010 972 ret=game->get_continue_dmap()*10000;
8011 972 break;
8012
8013 case GAMEENTRSCR:
8014 14 ret=lastentrance*10000;
8015 14 break;
8016
8017 case GAMEENTRDMAP:
8018 471 ret=lastentrance_dmap*10000;
8019 471 break;
8020
8021 case GAMECOUNTERD:
8022 4033084 ret=game->get_counter((ri->d[rINDEX])/10000)*10000;
8023 4033084 break;
8024
8025 case GAMEMCOUNTERD:
8026 1608203 ret=game->get_maxcounter((ri->d[rINDEX])/10000)*10000;
8027 1608203 break;
8028
8029 case GAMEDCOUNTERD:
8030 15 ret=game->get_dcounter((ri->d[rINDEX])/10000)*10000;
8031 15 break;
8032
8033 case GAMEGENERICD:
8034 856 ret=game->get_generic((ri->d[rINDEX])/10000)*10000;
8035 856 break;
8036
8037 case GAMEMISC:
8038 {
8039 int32_t indx = ri->d[rINDEX]/10000;
8040 if ( indx < 0 || indx > 31 )
8041 {
8042 ret = -10000;
8043 Z_scripterrlog("Invalud index used to access Game->Misc: %d\n", indx);
8044 }
8045 else
8046 {
8047 ret = QMisc.questmisc[indx]*((get_qr(qr_OLDQUESTMISC)) ? 10000 : 1);
8048 }
8049 break;
8050 }
8051
8052 case GAMEITEMSD:
8053 ret=(game->item[(ri->d[rINDEX])/10000] ? 10000 : 0);
8054 break;
8055 case DISABLEDITEM:
8056 ret = (game->items_off[(ri->d[rINDEX])/10000] ? 10000 : 0);
8057 break;
8058 case GAMESUSPEND:
8059 {
8060 700 int32_t inx = (ri->d[rINDEX])/10000;
8061
1/2
✓ Branch 0 taken 700 times.
✗ Branch 1 not taken.
700 if ( (unsigned) inx > (susptLAST-1) )
8062 {
8063 Z_scripterrlog("Invalid array index [%d] passed to Gme->Suspend[]\n");
8064 }
8065 700 ret = (( FFCore.system_suspend[inx] ) ? 10000 : 0);
8066 700 break;
8067 }
8068 case GAMELITEMSD:
8069 2369090 ret=game->lvlitems[(ri->d[rINDEX])/10000]*10000;
8070 2369090 break;
8071 case GAMELSWITCH:
8072 {
8073 int32_t ind = (ri->d[rINDEX])/10000;
8074 if(unsigned(ind) >= MAXLEVELS)
8075 ret = 0;
8076 else ret=game->lvlswitches[ind];
8077 break;
8078 }
8079 case GAMEGSWITCH:
8080 {
8081 int32_t ind = (ri->d[rINDEX])/10000;
8082 if(unsigned(ind) >= NUM_GSWITCHES)
8083 ret = 0;
8084 else ret=game->gswitch_timers[ind]*10000;
8085 break;
8086 }
8087 case GAMEBOTTLEST:
8088 ret=game->get_bottle_slot((ri->d[rINDEX])/10000)*10000;
8089 break;
8090
8091 case GAMELKEYSD:
8092 561833 ret=game->lvlkeys[(ri->d[rINDEX])/10000]*10000;
8093 561833 break;
8094
8095 case TANGOARR:
8096 {
8097 int32_t inx = (ri->d[rINDEX])/10000;
8098 if ( ((unsigned)inx) > 255 )
8099 {
8100 Z_scripterrlog("Invalid index %d supplied to Game->Tango[].\n", inx);
8101 ret = -10000;
8102 break;
8103 }
8104 else
8105 {
8106 ret=FFCore.TangoArray[inx]*10000;
8107 break;
8108 }
8109 }
8110 case GHOSTARR:
8111 {
8112 int32_t inx = (ri->d[rINDEX])/10000;
8113 if ( ((unsigned)inx) > 255 )
8114 {
8115 Z_scripterrlog("Invalid index %d supplied to Game->Ghost[].\n", inx);
8116 ret = -10000;
8117 break;
8118 }
8119 else
8120 {
8121 ret=FFCore.GhostArray[inx]*10000;
8122 break;
8123 }
8124 }
8125 case STDARR:
8126 {
8127 int32_t inx = (ri->d[rINDEX])/10000;
8128 if ( ((unsigned)inx) > 255 )
8129 {
8130 Z_scripterrlog("Invalid index %d supplied to Game->STD[].\n", inx);
8131 ret = -10000;
8132 break;
8133 }
8134 else
8135 {
8136 ret=FFCore.StdArray[inx]*10000;
8137 break;
8138 }
8139 }
8140
8141 case GAMEMISCSPR:
8142 {
8143 int32_t inx = (ri->d[rINDEX])/10000;
8144 if ( ((unsigned)inx) > sprMAX )
8145 {
8146 Z_scripterrlog("Invalid index %d supplied to Game->MiscSprites[].\n", inx);
8147 ret = -10000;
8148 }
8149 else
8150 {
8151 ret = QMisc.sprites[inx] * 10000;
8152 }
8153 break;
8154 }
8155 case GAMEMISCSFX:
8156 {
8157 int32_t inx = (ri->d[rINDEX])/10000;
8158 if ( ((unsigned)inx) > sfxMAX )
8159 {
8160 Z_scripterrlog("Invalid index %d supplied to Game->MiscSFX[].\n", inx);
8161 ret = -10000;
8162 }
8163 else
8164 {
8165 ret = QMisc.miscsfx[inx] * 10000;
8166 }
8167 break;
8168 }
8169 case GAMEEVENTDATA:
8170 {
8171 int32_t inx = (ri->d[rINDEX])/10000;
8172 ret = 0;
8173 if ( ((unsigned)inx) < FFCore.eventData.size() )
8174 {
8175 ret = FFCore.eventData[inx];
8176 }
8177 break;
8178 }
8179 case GAMEMOUSECURSOR:
8180 {
8181 ret = game_mouse_index*10000;
8182 break;
8183 }
8184 case GAMETRIGGROUPS:
8185 {
8186 int32_t ind = (ri->d[rINDEX])/10000;
8187 if(unsigned(ind)>255)
8188 Z_scripterrlog("Invalid index %d supplied to Game->TrigGroups[]\n",ind);
8189 ret = get_trig_group(ind)*10000;
8190 break;
8191 }
8192
8193 case GAMEGRAVITY:
8194 {
8195 int32_t indx = ri->d[rINDEX]/10000;
8196 if ( ((unsigned)indx) > 2 )
8197 //if(indx < 0 || indx > 2)
8198 {
8199 ret = -10000;
8200 Z_scripterrlog("Invalid index used to access Game->Gravity[]: %d\n", indx);
8201 }
8202 else
8203 {
8204 switch(indx)
8205 {
8206 case 0: //Gravity Strength
8207 ret = zinit.gravity2;
8208 break;
8209 case 1: //Terminal Velocity
8210 ret = zinit.terminalv * 100;
8211 break;
8212 case 2: //Sprite Layer Threshold
8213 ret = zinit.jump_hero_layer_threshold * 10000;
8214 break;
8215 }
8216 }
8217 break;
8218 }
8219
8220 case GAMESCROLLING:
8221 {
8222 191517 int32_t indx = ri->d[rINDEX]/10000;
8223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 191517 times.
191517 if ( ((unsigned)indx) >= SZ_SCROLLDATA )
8224 //if(indx < 0 || indx >= SZ_SCROLLDATA)
8225 {
8226 Z_scripterrlog("Invalid index used to access Game->Scrolling[]: %d\n", indx);
8227 }
8228 else
8229 {
8230 191517 ret = FFCore.ScrollingData[indx] * 10000L;
8231 }
8232 191517 break;
8233 }
8234
8235
8236 case SCREENSTATED:
8237 {
8238 1218351 int32_t mi = get_mi(MAPSCR_TEMP0);
8239
1/2
✓ Branch 0 taken 1218351 times.
✗ Branch 1 not taken.
1218351 if(mi<0) {ret = 0;break;}
8240 1218351 ret=((game->maps[mi]>>((ri->d[rINDEX]/10000)))&1)?10000:0;
8241 }
8242 1218351 break;
8243 case SCREENEXSTATED:
8244 {
8245 int32_t mi = get_mi(MAPSCR_TEMP0);
8246 if(mi<0) {ret = 0;break;}
8247 ret=((game->xstates[mi]>>((ri->d[rINDEX]/10000)))&1)?10000:0;
8248 }
8249 break;
8250 case SCREENLENSSHOWS:
8251 {
8252 int ind = ri->d[rINDEX]/10000;
8253 if(ind < 0 || ind > 6)
8254 Z_scripterrlog("Bad index Screen->LensShows[%d]\n",ind);
8255 else ret = (tmpscr->lens_show & (1<<ind)) ? 10000 : 0;
8256 break;
8257 }
8258 case SCREENLENSHIDES:
8259 {
8260 int ind = ri->d[rINDEX]/10000;
8261 if(ind < 0 || ind > 6)
8262 Z_scripterrlog("Bad index Screen->LensHides[%d]\n",ind);
8263 else ret = (tmpscr->lens_hide & (1<<ind)) ? 10000 : 0;
8264 break;
8265 }
8266
8267 case DISTANCE:
8268 {
8269 225833 double x1 = double(ri->d[rSFTEMP] / 10000.0);
8270 225833 double y1 = double(ri->d[rINDEX] / 10000.0);
8271 225833 double x2 = double(ri->d[rINDEX2] / 10000.0);
8272 225833 double y2 = double(ri->d[rEXP1] / 10000.0);
8273
8274
8275
8276 225833 int32_t result = FFCore.Distance(x1, y1, x2, y2);
8277 225833 ret = (result);
8278
8279 225833 break;
8280 }
8281 case LONGDISTANCE:
8282 {
8283 double x1 = double(ri->d[rSFTEMP]);
8284 double y1 = double(ri->d[rINDEX]);
8285 double x2 = double(ri->d[rINDEX2]);
8286 double y2 = double(ri->d[rEXP1]);
8287
8288
8289
8290 int32_t result = FFCore.LongDistance(x1, y1, x2, y2);
8291 ret = (result);
8292
8293 break;
8294 }
8295
8296 case DISTANCESCALE:
8297 {
8298 double x1 = (double)(ri->d[rSFTEMP] / 10000.0);
8299 zprint2("x1 is: %f\n", x1);
8300 double y1 = (double)(ri->d[rINDEX] / 10000.0);
8301 zprint2("y1 is: %f\n", y1);
8302 double x2 = (double)(ri->d[rINDEX2] / 10000.0);
8303 zprint2("x2 is: %f\n", x2);
8304 double y2 = (double)(ri->d[rEXP1] / 10000.0);
8305 zprint2("y2 is: %f\n", y2);
8306
8307 int32_t scale = (ri->d[rWHAT_NO_7]/10000);
8308 zprint2("Scale is: %d\n", scale);
8309
8310 if ( !scale ) scale = 10000;
8311 int32_t result = FFCore.Distance(x1, y1, x2, y2, scale);
8312 ret = (result);
8313
8314 break;
8315 }
8316 case LONGDISTANCESCALE:
8317 {
8318 double x1 = (double)(ri->d[rSFTEMP]);
8319 zprint2("x1 is: %f\n", x1);
8320 double y1 = (double)(ri->d[rINDEX]);
8321 zprint2("y1 is: %f\n", y1);
8322 double x2 = (double)(ri->d[rINDEX2]);
8323 zprint2("x2 is: %f\n", x2);
8324 double y2 = (double)(ri->d[rEXP1]);
8325 zprint2("y2 is: %f\n", y2);
8326
8327 int32_t scale = (ri->d[rWHAT_NO_7]);
8328 zprint2("Scale is: %d\n", scale);
8329
8330 if ( !scale ) scale = 1;
8331 int32_t result = FFCore.LongDistance(x1, y1, x2, y2, scale);
8332 ret = (result);
8333
8334 break;
8335 }
8336
8337 case SCREENSTATEDD:
8338 {
8339 // Gah! >:( Screen state is stored in game->maps, which uses 128 screens per map,
8340 // but the compiler multiplies the map number by 136, so it has to be corrected here.
8341 // Yeah, the compiler could be fixed, but that wouldn't cover existing quests...
8342 18739404 int32_t mi = ri->d[rINDEX] / 10000;
8343 18739404 mi -= 8*((ri->d[rINDEX] / 10000) / MAPSCRS);
8344
8345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18739404 times.
18739404 if(BC::checkMapID(mi>>7, "Game->GetScreenState") == SH::_NoError)
8346 18739404 ret=(game->maps[mi] >> (ri->d[rINDEX2] / 10000) & 1) ? 10000 : 0;
8347 else
8348 ret=0;
8349
8350 18739404 break;
8351 }
8352
8353 case GAMEGUYCOUNTD:
8354 ret=game->guys[(currmap * MAPSCRSNORMAL) + (ri->d[rINDEX] / 10000)]*10000;
8355 break;
8356
8357 case CURMAP:
8358 22596070 ret=(1+currmap)*10000;
8359 22596070 break;
8360
8361 case CURSCR:
8362 14112447 ret=currscr*10000;
8363 14112447 break;
8364
8365 case ALLOCATEBITMAPR:
8366 125 ret=FFCore.do_allocate_bitmap();
8367 125 break;
8368
8369 case GETMIDI:
8370 63717 ret=(currmidi-(ZC_MIDI_COUNT-1))*10000;
8371 63717 break;
8372
8373 case CURDSCR:
8374 {
8375 5921351 int32_t di = (get_currscr()-DMaps[get_currdmap()].xoff);
8376
2/2
✓ Branch 0 taken 3035425 times.
✓ Branch 1 taken 2885926 times.
5921351 ret=(DMaps[get_currdmap()].type==dmOVERW ? currscr : di)*10000;
8377 }
8378 5921351 break;
8379
8380 case GAMEMAXMAPS:
8381 ret = (map_count)*10000;
8382 break;
8383 case GAMENUMMESSAGES:
8384 ret = (msg_count-1) * 10000;
8385 break;
8386
8387 case CURDMAP:
8388 49232485 ret=currdmap*10000;
8389 49232485 break;
8390
8391 case CURLEVEL:
8392 14025143 ret=DMaps[get_currdmap()].level*10000;
8393 14025143 break;
8394
8395 case GAMECLICKFREEZE:
8396 ret=disableClickToFreeze?0:10000;
8397 break;
8398
8399
8400 case NOACTIVESUBSC:
8401 ret=Hero.stopSubscreenFalling()?10000:0;
8402 break;///----------------------------------------------------------------------------------------------------//
8403 //BottleTypes
8404 case BOTTLECOUNTER:
8405 {
8406 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Counter[]"))
8407 {
8408 int32_t indx = ri->d[rINDEX]/10000;
8409 if(unsigned(indx) > 2)
8410 {
8411 Z_scripterrlog("Invalid index %d supplied to bottledata->Counter[].\n", indx);
8412 ret = -10000L;
8413 break;
8414 }
8415 ret = 10000L * ptr->counter[indx];
8416 }
8417 else ret = -10000L;
8418 }
8419 break;
8420
8421 case BOTTLEAMOUNT:
8422 {
8423 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Amount[]"))
8424 {
8425 int32_t indx = ri->d[rINDEX]/10000;
8426 if(unsigned(indx) > 2)
8427 {
8428 Z_scripterrlog("Invalid index %d supplied to bottledata->Amount[].\n", indx);
8429 ret = -10000L;
8430 break;
8431 }
8432 ret = 10000L * ptr->amount[indx];
8433 }
8434 else ret = -10000L;
8435 }
8436 break;
8437
8438 case BOTTLEPERCENT:
8439 {
8440 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "IsPercent[]"))
8441 {
8442 int32_t indx = ri->d[rINDEX]/10000;
8443 if(unsigned(indx) > 2)
8444 {
8445 Z_scripterrlog("Invalid index %d supplied to bottledata->IsPercent[].\n", indx);
8446 ret = -10000L;
8447 break;
8448 }
8449 ret = (ptr->flags & (1<<indx)) ? 10000L : 0;
8450 }
8451 else ret = -10000L;
8452 }
8453 break;
8454
8455 case BOTTLEFLAGS:
8456 {
8457 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Flags[]"))
8458 {
8459 int32_t indx = ri->d[rINDEX]/10000;
8460 if(unsigned(indx) > 3)
8461 {
8462 Z_scripterrlog("Invalid index %d supplied to bottledata->Flags[].\n", indx);
8463 ret = -10000L;
8464 break;
8465 }
8466 int32_t flag = 0;
8467 switch(indx)
8468 {
8469 case 0: flag = BTFLAG_AUTOONDEATH; break;
8470 case 1: flag = BTFLAG_ALLOWIFFULL; break;
8471 case 2: flag = BTFLAG_CURESWJINX; break;
8472 case 3: flag = BTFLAG_CUREITJINX; break;
8473 }
8474 ret = (ptr->flags & flag) ? 10000L : 0;
8475 }
8476 else ret = -10000L;
8477 }
8478 break;
8479
8480 case BOTTLENEXT:
8481 {
8482 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "NextType"))
8483 {
8484 ret = 10000L * ptr->next_type;
8485 }
8486 else ret = -10000L;
8487 }
8488 break;
8489 ///----------------------------------------------------------------------------------------------------//
8490 //BottleShops
8491 case BSHOPFILL:
8492 {
8493 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Fill[]"))
8494 {
8495 int32_t indx = ri->d[rINDEX]/10000;
8496 if(unsigned(indx) > 2)
8497 {
8498 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Fill[].\n", indx);
8499 ret = -10000L;
8500 break;
8501 }
8502 ret = 10000L * ptr->fill[indx];
8503 }
8504 else ret = -10000L;
8505 }
8506 break;
8507
8508 case BSHOPCOMBO:
8509 {
8510 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Combo[]"))
8511 {
8512 int32_t indx = ri->d[rINDEX]/10000;
8513 if(unsigned(indx) > 2)
8514 {
8515 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Combo[].\n", indx);
8516 ret = -10000L;
8517 break;
8518 }
8519 ret = 10000L * ptr->comb[indx];
8520 }
8521 else ret = -10000L;
8522 }
8523 break;
8524
8525 case BSHOPCSET:
8526 {
8527 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "CSet[]"))
8528 {
8529 int32_t indx = ri->d[rINDEX]/10000;
8530 if(unsigned(indx) > 2)
8531 {
8532 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->CSet[].\n", indx);
8533 ret = -10000L;
8534 break;
8535 }
8536 ret = 10000L * ptr->cset[indx];
8537 }
8538 else ret = -10000L;
8539 }
8540 break;
8541
8542 case BSHOPPRICE:
8543 {
8544 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Price[]"))
8545 {
8546 int32_t indx = ri->d[rINDEX]/10000;
8547 if(unsigned(indx) > 2)
8548 {
8549 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Price[].\n", indx);
8550 ret = -10000L;
8551 break;
8552 }
8553 ret = 10000L * ptr->price[indx];
8554 }
8555 else ret = -10000L;
8556 }
8557 break;
8558
8559 case BSHOPSTR:
8560 {
8561 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "InfoString[]"))
8562 {
8563 int32_t indx = ri->d[rINDEX]/10000;
8564 if(unsigned(indx) > 2)
8565 {
8566 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->InfoString[].\n", indx);
8567 ret = -10000L;
8568 break;
8569 }
8570 ret = 10000L * ptr->str[indx];
8571 }
8572 else ret = -10000L;
8573 }
8574 break;
8575
8576 ///----------------------------------------------------------------------------------------------------//
8577 //DMap Information
8578
8579 #define GET_DMAP_VAR(member, str) \
8580 { \
8581 int32_t ID = ri->d[rINDEX] / 10000; \
8582 if(BC::checkDMapID(ID, str) != SH::_NoError) \
8583 ret = -10000; \
8584 else \
8585 ret = DMaps[ID].member * 10000; \
8586 }
8587
8588 case DMAPFLAGSD:
8589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1764243 times.
1764243 GET_DMAP_VAR(flags, "Game->DMapFlags") break;
8590
8591 case DMAPLEVELD:
8592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1019 times.
1019 GET_DMAP_VAR(level, "Game->DMapLevel") break;
8593
8594 case DMAPCOMPASSD:
8595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255560 times.
255560 GET_DMAP_VAR(compass, "Game->DMapCompass") break;
8596
8597 case DMAPCONTINUED:
8598 GET_DMAP_VAR(cont, "Game->DMapContinue") break;
8599
8600 case DMAPLEVELPAL:
8601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 741668 times.
741668 GET_DMAP_VAR(color, "Game->DMapPalette") break;
8602
8603 case DMAPOFFSET:
8604
1/2
✓ Branch 0 taken 96115 times.
✗ Branch 1 not taken.
96115 GET_DMAP_VAR(xoff, "Game->DMapOffset") break;
8605
8606 case DMAPMAP:
8607 {
8608 9482 int32_t ID = ri->d[rINDEX] / 10000;
8609
8610
1/2
✓ Branch 0 taken 9482 times.
✗ Branch 1 not taken.
9482 if(BC::checkDMapID(ID, "Game->DMapMap") != SH::_NoError)
8611 ret = -10000;
8612 else
8613 9482 ret = (DMaps[ID].map+1) * 10000;
8614
8615 9482 break;
8616 }
8617
8618 case DMAPMIDID:
8619 {
8620 37 int32_t ID = ri->d[rINDEX] / 10000;
8621
8622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(BC::checkDMapID(ID, "Game->DMapMIDI") == SH::_NoError)
8623 {
8624 // Based on play_DmapMusic
8625
2/5
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
37 switch(DMaps[ID].midi)
8626 {
8627 case 2:
8628 ret = -60000;
8629 break; // Dungeon
8630
8631 case 3:
8632 ret = -30000;
8633 break; // Level 9
8634
8635 case 1:
8636 ret = -20000;
8637 break; // Overworld
8638
8639 case 0:
8640 4 ret = 0;
8641 4 break; // None
8642
8643 default:
8644 33 ret = (DMaps[ID].midi - 3) * 10000;
8645 33 }
8646 37 }
8647 else
8648 ret = -10000; // Which is valid, but whatever.
8649
8650 37 break;
8651 }
8652
8653 ///----------------------------------------------------------------------------------------------------//
8654 //Screen->ComboX
8655 #define GET_COMBO_VAR(member, str) \
8656 { \
8657 int32_t pos = ri->d[rINDEX] / 10000; \
8658 if(BC::checkComboPos(pos, str) != SH::_NoError) \
8659 { \
8660 ret = -10000; \
8661 } \
8662 else \
8663 ret = tmpscr->member[pos]*10000; \
8664 }
8665
8666 case COMBODD:
8667
1/2
✓ Branch 0 taken 27341446 times.
✗ Branch 1 not taken.
27341446 GET_COMBO_VAR(data, "Screen->ComboD[]") break;
8668
8669 case COMBOCD:
8670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2709583 times.
2709583 GET_COMBO_VAR(cset, "Screen->ComboC[]") break;
8671
8672 case COMBOFD:
8673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3906008 times.
3906008 GET_COMBO_VAR(sflag, "Screen->ComboF[]") break;
8674
8675 #define GET_COMBO_VAR_BUF(member, str) \
8676 { \
8677 int32_t pos = ri->d[rINDEX] / 10000; \
8678 if(BC::checkComboPos(pos, str) != SH::_NoError) \
8679 { \
8680 ret = -10000; \
8681 } \
8682 else \
8683 ret = combobuf[tmpscr->data[pos]].member * 10000; \
8684 }
8685
8686 case COMBOTD:
8687
1/2
✓ Branch 0 taken 26493228 times.
✗ Branch 1 not taken.
26493228 GET_COMBO_VAR_BUF(type, "Screen->ComboT[]") break;
8688
8689 case COMBOID:
8690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2974800 times.
2974800 GET_COMBO_VAR_BUF(flag, "Screen->ComboI[]") break;
8691
8692 case COMBOSD:
8693 {
8694 96784 int32_t pos = ri->d[rINDEX] / 10000;
8695
8696
2/2
✓ Branch 0 taken 95200 times.
✓ Branch 1 taken 1584 times.
96784 if(BC::checkComboPos(pos, "Screen->ComboS[]") != SH::_NoError)
8697 1584 ret = -10000;
8698 else
8699 95200 ret = (combobuf[tmpscr->data[pos]].walk & 0xF) * 10000;
8700 }
8701 96784 break;
8702
8703 case COMBOED:
8704 {
8705 int32_t pos = ri->d[rINDEX] / 10000;
8706
8707 if(BC::checkComboPos(pos, "Screen->ComboE[]") != SH::_NoError)
8708 ret = -10000;
8709 else
8710 ret = ((combobuf[tmpscr->data[pos]].walk & 0xF0)>>4) * 10000;
8711 }
8712 break;
8713
8714 ///----------------------------------------------------------------------------------------------------//
8715 //Game->GetComboX
8716
8717 case COMBODDM:
8718 {
8719 13758809 int32_t pos = (ri->d[rINDEX])/10000;
8720 13758809 int32_t sc = (ri->d[rEXP1]/10000);
8721 13758809 int32_t m = (ri->d[rINDEX2]/10000)-1;
8722
2/2
✓ Branch 0 taken 11881062 times.
✓ Branch 1 taken 1877747 times.
13758809 int32_t scr = zc_max(m*MAPSCRS+sc,0);
8723 13758809 int32_t layr = whichlayer(scr);
8724
8725
2/4
✓ Branch 0 taken 13758809 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13758809 times.
13758809 if(pos < 0 || pos >= 176)
8726 {
8727 Z_scripterrlog("Invalid combo position (%d) passed to GetComboData", pos);
8728 ret = -10000;
8729 }
8730
1/2
✓ Branch 0 taken 13758809 times.
✗ Branch 1 not taken.
13758809 else if(scr < 0)
8731 {
8732 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboData", scr);
8733 ret = -10000;
8734 }
8735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13758809 times.
13758809 else if(sc >= MAPSCRS)
8736 {
8737 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboData", sc);
8738 ret = -10000;
8739 }
8740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13758809 times.
13758809 else if(m >= map_count)
8741 {
8742 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboData", m);
8743 ret = -10000;
8744 }
8745
2/2
✓ Branch 0 taken 11885286 times.
✓ Branch 1 taken 1873523 times.
13758809 else if(m < 0) ret = 0; //No layer present
8746
8747 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
8748 else
8749 {
8750
2/2
✓ Branch 0 taken 109146 times.
✓ Branch 1 taken 11776140 times.
11885286 if(scr==(currmap*MAPSCRS+currscr))
8751 109146 ret=tmpscr->data[pos]*10000;
8752
2/2
✓ Branch 0 taken 5826733 times.
✓ Branch 1 taken 5949407 times.
11776140 else if(layr>-1)
8753 5826733 ret=tmpscr2[layr].data[pos]*10000;
8754 5949407 else ret=TheMaps[scr].data[pos]*10000;
8755 }
8756
8757 }
8758 13758809 break;
8759
8760 case COMBOCDM:
8761 {
8762 2272124 int32_t pos = (ri->d[rINDEX])/10000;
8763 2272124 int32_t sc = (ri->d[rEXP1]/10000);
8764 2272124 int32_t m = (ri->d[rINDEX2]/10000)-1;
8765
1/2
✓ Branch 0 taken 2272124 times.
✗ Branch 1 not taken.
2272124 int32_t scr = zc_max(m*MAPSCRS+sc,0);
8766 2272124 int32_t layr = whichlayer(scr);
8767
8768
2/4
✓ Branch 0 taken 2272124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2272124 times.
2272124 if(pos < 0 || pos >= 176)
8769 {
8770 Z_scripterrlog("Invalid combo position (%d) passed to GetComboCSet", pos);
8771 ret = -10000;
8772 }
8773
1/2
✓ Branch 0 taken 2272124 times.
✗ Branch 1 not taken.
2272124 else if(scr < 0)
8774 {
8775 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboCSet", scr);
8776 ret = -10000;
8777 }
8778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2272124 times.
2272124 else if(sc >= MAPSCRS)
8779 {
8780 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboCSet", sc);
8781 ret = -10000;
8782 }
8783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2272124 times.
2272124 else if(m >= map_count)
8784 {
8785 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboCSet", m);
8786 ret = -10000;
8787 }
8788
1/2
✓ Branch 0 taken 2272124 times.
✗ Branch 1 not taken.
2272124 else if(m < 0) ret = 0; //No layer present
8789
8790 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
8791 else
8792 {
8793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2272124 times.
2272124 if(scr==(currmap*MAPSCRS+currscr))
8794 ret=tmpscr->cset[pos]*10000;
8795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2272124 times.
2272124 else if(layr>-1)
8796 ret=tmpscr2[layr].cset[pos]*10000;
8797 2272124 else ret=TheMaps[scr].cset[pos]*10000;
8798 }
8799
8800 }
8801 2272124 break;
8802
8803 case COMBOFDM:
8804 {
8805 5866709 int32_t pos = (ri->d[rINDEX])/10000;
8806 5866709 int32_t sc = (ri->d[rEXP1]/10000);
8807 5866709 int32_t m = (ri->d[rINDEX2]/10000)-1;
8808
1/2
✓ Branch 0 taken 5866709 times.
✗ Branch 1 not taken.
5866709 int32_t scr = zc_max(m*MAPSCRS+sc,0);
8809 5866709 int32_t layr = whichlayer(scr);
8810
8811
3/4
✓ Branch 0 taken 5866709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4000 times.
✓ Branch 3 taken 5862709 times.
5866709 if(pos < 0 || pos >= 176)
8812 {
8813 4000 Z_scripterrlog("Invalid combo position (%d) passed to GetComboFlag", pos);
8814 4000 ret = -10000;
8815 4000 }
8816
1/2
✓ Branch 0 taken 5862709 times.
✗ Branch 1 not taken.
5862709 else if(scr < 0)
8817 {
8818 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboFlag", scr);
8819 ret = -10000;
8820 }
8821
2/2
✓ Branch 0 taken 4212 times.
✓ Branch 1 taken 5858497 times.
5862709 else if(sc >= MAPSCRS)
8822 {
8823 4212 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboFlag", sc);
8824 4212 ret = -10000;
8825 4212 }
8826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5858497 times.
5858497 else if(m >= map_count)
8827 {
8828 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboFlag", m);
8829 ret = -10000;
8830 }
8831
1/2
✓ Branch 0 taken 5858497 times.
✗ Branch 1 not taken.
5858497 else if(m < 0) ret = 0; //No layer present
8832 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
8833 else
8834 {
8835
2/2
✓ Branch 0 taken 317735 times.
✓ Branch 1 taken 5540762 times.
5858497 if(scr==(currmap*MAPSCRS+currscr))
8836 317735 ret=tmpscr->sflag[pos]*10000;
8837
2/2
✓ Branch 0 taken 4629060 times.
✓ Branch 1 taken 911702 times.
5540762 else if(layr>-1)
8838 4629060 ret=tmpscr2[layr].sflag[pos]*10000;
8839 911702 else ret=TheMaps[scr].sflag[pos]*10000;
8840 }
8841
8842 }
8843 5866709 break;
8844
8845 case COMBOTDM:
8846 {
8847 449777 int32_t pos = (ri->d[rINDEX])/10000;
8848 449777 int32_t sc = (ri->d[rEXP1]/10000);
8849 449777 int32_t m = (ri->d[rINDEX2]/10000)-1;
8850
1/2
✓ Branch 0 taken 449777 times.
✗ Branch 1 not taken.
449777 int32_t scr = zc_max(m*MAPSCRS+sc,0);
8851 449777 int32_t layr = whichlayer(scr);
8852
8853
2/4
✓ Branch 0 taken 449777 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 449777 times.
449777 if(pos < 0 || pos >= 176)
8854 {
8855 Z_scripterrlog("Invalid combo position (%d) passed to GetComboType", pos);
8856 ret = -10000;
8857 }
8858
1/2
✓ Branch 0 taken 449777 times.
✗ Branch 1 not taken.
449777 else if(scr < 0)
8859 {
8860 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboType", scr);
8861 ret = -10000;
8862 }
8863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 449777 times.
449777 else if(sc >= MAPSCRS)
8864 {
8865 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboType", sc);
8866 ret = -10000;
8867 }
8868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 449777 times.
449777 else if(m >= map_count)
8869 {
8870 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboType", m);
8871 ret = -10000;
8872 }
8873
1/2
✓ Branch 0 taken 449777 times.
✗ Branch 1 not taken.
449777 else if(m < 0) ret = 0; //No layer present
8874
8875 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
8876 else
8877 {
8878
2/2
✓ Branch 0 taken 106581 times.
✓ Branch 1 taken 343196 times.
449777 if(scr==(currmap*MAPSCRS+currscr))
8879 106581 ret=combobuf[tmpscr->data[pos]].type*10000;
8880
2/2
✓ Branch 0 taken 105393 times.
✓ Branch 1 taken 237803 times.
343196 else if(layr>-1)
8881 105393 ret=combobuf[tmpscr2[layr].data[pos]].type*10000;
8882 713409 else ret=combobuf[
8883 713409 TheMaps[scr].data[pos]].type*10000;
8884 }
8885 }
8886 449777 break;
8887
8888 case COMBOIDM:
8889 {
8890 421915 int32_t pos = (ri->d[rINDEX])/10000;
8891 421915 int32_t sc = (ri->d[rEXP1]/10000);
8892 421915 int32_t m = (ri->d[rINDEX2]/10000)-1;
8893
1/2
✓ Branch 0 taken 421915 times.
✗ Branch 1 not taken.
421915 int32_t scr = zc_max(m*MAPSCRS+sc,0);
8894 421915 int32_t layr = whichlayer(scr);
8895
8896
3/4
✓ Branch 0 taken 421915 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4000 times.
✓ Branch 3 taken 417915 times.
421915 if(pos < 0 || pos >= 176)
8897 {
8898 4000 Z_scripterrlog("Invalid combo position (%d) passed to GetComboInherentFlag", pos);
8899 4000 ret = -10000;
8900 4000 }
8901
1/2
✓ Branch 0 taken 417915 times.
✗ Branch 1 not taken.
417915 else if(scr < 0)
8902 {
8903 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboInherentFlag", scr);
8904 ret = -10000;
8905 }
8906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 417915 times.
417915 else if(sc >= MAPSCRS)
8907 {
8908 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboInherentFlag", sc);
8909 ret = -10000;
8910 }
8911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 417915 times.
417915 else if(m >= map_count)
8912 {
8913 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboInherentFlag", m);
8914 ret = -10000;
8915 }
8916
1/2
✓ Branch 0 taken 417915 times.
✗ Branch 1 not taken.
417915 else if(m < 0) ret = 0; //No layer present
8917
8918 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
8919 else
8920 {
8921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 417915 times.
417915 if(scr==(currmap*MAPSCRS+currscr))
8922 ret=combobuf[tmpscr->data[pos]].flag*10000;
8923
1/2
✓ Branch 0 taken 417915 times.
✗ Branch 1 not taken.
417915 else if(layr>-1)
8924 417915 ret=combobuf[tmpscr2[layr].data[pos]].flag*10000;
8925 else ret=combobuf[TheMaps[scr].data[pos]].flag*10000;
8926 }
8927 }
8928 421915 break;
8929
8930 case COMBOSDM:
8931 {
8932 6342577 int32_t pos = (ri->d[rINDEX])/10000;
8933 6342577 int32_t sc = (ri->d[rEXP1]/10000);
8934 6342577 int32_t m = (ri->d[rINDEX2]/10000)-1;
8935
2/2
✓ Branch 0 taken 6341872 times.
✓ Branch 1 taken 705 times.
6342577 int32_t scr = zc_max(m*MAPSCRS+sc,0);
8936 6342577 int32_t layr = whichlayer(scr);
8937
8938
2/4
✓ Branch 0 taken 6342577 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6342577 times.
6342577 if(pos < 0 || pos >= 176)
8939 {
8940 Z_scripterrlog("Invalid combo position (%d) passed to GetComboSolid", pos);
8941 ret = -10000;
8942 }
8943
1/2
✓ Branch 0 taken 6342577 times.
✗ Branch 1 not taken.
6342577 else if(scr < 0)
8944 {
8945 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboSolid", scr);
8946 ret = -10000;
8947 }
8948
2/2
✓ Branch 0 taken 2106 times.
✓ Branch 1 taken 6340471 times.
6342577 else if(sc >= MAPSCRS)
8949 {
8950 2106 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboSolid", sc);
8951 2106 ret = -10000;
8952 2106 }
8953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6340471 times.
6340471 else if(m >= map_count)
8954 {
8955 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboSolid", m);
8956 ret = -10000;
8957 }
8958
2/2
✓ Branch 0 taken 6339767 times.
✓ Branch 1 taken 704 times.
6340471 else if(m < 0) ret = 0; //No layer present
8959
8960 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
8961 else
8962 {
8963
2/2
✓ Branch 0 taken 581032 times.
✓ Branch 1 taken 5758735 times.
6339767 if(scr==(currmap*MAPSCRS+currscr))
8964 581032 ret=(combobuf[tmpscr->data[pos]].walk&15)*10000;
8965
2/2
✓ Branch 0 taken 644433 times.
✓ Branch 1 taken 5114302 times.
5758735 else if(layr>-1)
8966 644433 ret=(combobuf[tmpscr2[layr].data[pos]].walk&15)*10000;
8967 5114302 else ret=(combobuf[TheMaps[scr].data[pos]].walk&15)*10000;
8968 }
8969
8970 }
8971 6342577 break;
8972
8973
8974
8975
8976 ///----------------------------------------------------------------------------------------------------//
8977 //Screen Information
8978
8979 #define GET_SCREENDATA_VAR_INT32(member, str) \
8980 { \
8981 ret = (tmpscr->member *10000); \
8982 } \
8983
8984 #define GET_SCREENDATA_VAR_INT16(member, str) \
8985 { \
8986 ret = (tmpscr->member *10000); \
8987 } \
8988
8989 #define GET_SCREENDATA_VAR_BYTE(member, str) \
8990 { \
8991 ret = (tmpscr->member *10000); \
8992 } \
8993
8994 #define GET_SCREENDATA_VAR_INDEX32(member, str, indexbound) \
8995 { \
8996 int32_t indx = ri->d[rINDEX] / 10000; \
8997 ret = (tmpscr->member[indx] *10000); \
8998 } \
8999
9000 #define GET_SCREENDATA_VAR_INDEX16(member, str, indexbound) \
9001 { \
9002 int32_t indx = ri->d[rINDEX] / 10000; \
9003 ret = (tmpscr->member[indx] *10000); \
9004 } \
9005
9006 #define GET_SCREENDATA_BYTE_INDEX(member, str, indexbound) \
9007 { \
9008 int32_t indx = ri->d[rINDEX] / 10000; \
9009 ret = (tmpscr->member[indx] *10000); \
9010 } \
9011
9012 //byte
9013 #define GET_SCREENDATA_LAYER_INDEX(member, str, indexbound) \
9014 { \
9015 int32_t indx = ri->d[rINDEX] / 10000; \
9016 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
9017 if(indx < 1 || indx > indexbound ) \
9018 { \
9019 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", str, indx); \
9020 ret = -10000; \
9021 } \
9022 else \
9023 { \
9024 ret = (tmpscr->member[indx-1] *10000); \
9025 } \
9026 } \
9027
9028
9029 #define GET_SCREENDATA_BOOL_INDEX(member, str, indexbound) \
9030 { \
9031 int32_t indx = ri->d[rINDEX] / 10000; \
9032 if(indx < 0 || indx > indexbound ) \
9033 { \
9034 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", (indx), str); \
9035 ret = -10000; \
9036 } \
9037 else \
9038 { \
9039 ret = (tmpscr->member[indx]?10000:0); \
9040 } \
9041 } \
9042
9043 #define GET_FFC_BOOL_INDEX(member, str, indexbound) \
9044 { \
9045 int32_t indx = ri->d[rINDEX] / 10000; \
9046 if(indx < 0 || indx > indexbound ) \
9047 { \
9048 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", (indx), str); \
9049 ret = -10000; \
9050 } \
9051 else \
9052 { \
9053 ret = (tmpscr->ffcs[indx].member?10000:0); \
9054 } \
9055 } \
9056
9057
9058 #define GET_SCREENDATA_FLAG(member, str, indexbound) \
9059 { \
9060 int32_t flag = (value/10000); \
9061 ret = (tmpscr->member&flag) ? 10000 : 0); \
9062 } \
9063
9064 case SCREENDATAVALID: GET_SCREENDATA_VAR_BYTE(valid, "Valid"); break; //b
9065 case SCREENDATAGUY: GET_SCREENDATA_VAR_BYTE(guy, "Guy"); break; //b
9066 case SCREENDATASTRING: GET_SCREENDATA_VAR_INT32(str, "String"); break; //w
9067 case SCREENDATAROOM: GET_SCREENDATA_VAR_BYTE(room, "RoomType"); break; //b
9068 case SCREENDATAITEM:
9069 {
9070 if(tmpscr->hasitem)
9071 ret = (tmpscr->item *10000);
9072 else ret = -10000;
9073 break;
9074 }
9075 case SCREENDATAHASITEM: GET_SCREENDATA_VAR_BYTE(hasitem, "HasItem"); break; //b
9076 case SCREENDATATILEWARPTYPE: GET_SCREENDATA_BYTE_INDEX(tilewarptype, "TileWarpType", 3); break; //b, 4 of these
9077 //case SCREENDATATILEWARPOVFLAGS: GET_SCREENDATA_VAR_BYTE(tilewarpoverlayflags, "TileWarpOverlayFlags"); break; //b, tilewarpoverlayflags
9078 case SCREENDATADOORCOMBOSET: GET_SCREENDATA_VAR_INT32(door_combo_set, "DoorComboSet"); break; //w
9079 case SCREENDATAWARPRETX: GET_SCREENDATA_BYTE_INDEX(warpreturnx, "WarpReturnX", 3); break; //b, 4 of these
9080 case SCREENDATAWARPRETY: GET_SCREENDATA_BYTE_INDEX(warpreturny, "WarpReturnY", 3); break; //b, 4 of these
9081 case SCREENDATAWARPRETURNC: GET_SCREENDATA_VAR_INT32(warpreturnc, "WarpReturnC"); break; //w
9082 case SCREENDATASTAIRX: GET_SCREENDATA_VAR_BYTE(stairx, "StairsX"); break; //b
9083 case SCREENDATASTAIRY: GET_SCREENDATA_VAR_BYTE(stairy, "StairsY"); break; //b
9084 case SCREENDATAITEMX: GET_SCREENDATA_VAR_BYTE(itemx, "ItemX"); break; //itemx
9085 case SCREENDATAITEMY: GET_SCREENDATA_VAR_BYTE(itemy, "ItemY"); break; //itemy
9086 515 case SCREENDATACOLOUR: GET_SCREENDATA_VAR_INT32(color, "CSet"); break; //w
9087 case SCREENDATAENEMYFLAGS: GET_SCREENDATA_VAR_BYTE(enemyflags, "EnemyFlags"); break; //b
9088 case SCREENDATADOOR: GET_SCREENDATA_BYTE_INDEX(door, "Door", 3); break; //b, 4 of these
9089 case SCREENDATATILEWARPDMAP: GET_SCREENDATA_VAR_INDEX32(tilewarpdmap, "TileWarpDMap", 3); break; //w, 4 of these
9090 case SCREENDATATILEWARPSCREEN: GET_SCREENDATA_BYTE_INDEX(tilewarpscr, "TileWarpScreen", 3); break; //b, 4 of these
9091 case SCREENDATAEXITDIR: GET_SCREENDATA_VAR_BYTE(exitdir, "ExitDir"); break; //b
9092 case SCREENDATAENEMY: GET_SCREENDATA_VAR_INDEX32(enemy, "Enemy", 9); break; //w, 10 of these
9093 case SCREENDATAPATTERN: GET_SCREENDATA_VAR_BYTE(pattern, "Pattern"); break; //b
9094 case SCREENDATASIDEWARPTYPE: GET_SCREENDATA_BYTE_INDEX(sidewarptype, "SideWarpType", 3); break; //b, 4 of these
9095 //case SCREENDATASIDEWARPOVFLAGS: GET_SCREENDATA_VAR_BYTE(sidewarpoverlayflags, "SideWarpOverlayFlags"); break; //b
9096 case SCREENDATAWARPARRIVALX: GET_SCREENDATA_VAR_BYTE(warparrivalx, "WarpArrivalX"); break; //b
9097 case SCREENDATAWARPARRIVALY: GET_SCREENDATA_VAR_BYTE(warparrivaly, "WarpArrivalY"); break; //b
9098 case SCREENDATAPATH: GET_SCREENDATA_BYTE_INDEX(path, "MazePath", 3); break; //b, 4 of these
9099 case SCREENDATASIDEWARPSC: GET_SCREENDATA_BYTE_INDEX(sidewarpscr, "SideWarpScreen", 3); break; //b, 4 of these
9100 case SCREENDATASIDEWARPDMAP: GET_SCREENDATA_VAR_INDEX32(sidewarpdmap, "SideWarpDMap", 3); break; //w, 4 of these
9101 case SCREENDATASIDEWARPINDEX: GET_SCREENDATA_VAR_BYTE(sidewarpindex, "SideWarpIndex"); break; //b
9102 case SCREENDATAUNDERCOMBO: GET_SCREENDATA_VAR_INT32(undercombo, "Undercombo"); break; //w
9103 case SCREENDATAUNDERCSET: GET_SCREENDATA_VAR_BYTE(undercset, "UnderCSet"); break; //b
9104 case SCREENDATACATCHALL: GET_SCREENDATA_VAR_INT32(catchall, "Catchall"); break; //W
9105
9106 case SCREENDATACSENSITIVE: GET_SCREENDATA_VAR_BYTE(csensitive, "CSensitive"); break; //B
9107 case SCREENDATANORESET: GET_SCREENDATA_VAR_INT32(noreset, "NoReset"); break; //W
9108 case SCREENDATANOCARRY: GET_SCREENDATA_VAR_INT32(nocarry, "NoCarry"); break; //W
9109
3/6
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 54 times.
54 case SCREENDATALAYERMAP: GET_SCREENDATA_LAYER_INDEX(layermap, "LayerMap", 6); break; //B, 6 OF THESE
9110 case SCREENDATALAYERSCREEN: GET_SCREENDATA_LAYER_INDEX(layerscreen, "LayerScreen", 6); break; //B, 6 OF THESE
9111 case SCREENDATALAYEROPACITY: GET_SCREENDATA_LAYER_INDEX(layeropacity, "LayerOpacity", 6); break; //B, 6 OF THESE
9112 case SCREENDATALAYERINVIS:
9113 {
9114 int32_t indx = ri->d[rINDEX] / 10000;
9115 if(indx < 0 || indx > 6 )
9116 {
9117 Z_scripterrlog("Invalid Index passed to Screen->LayerInvisible[]: %d\n", indx);
9118 ret = 0;
9119 }
9120 else
9121 {
9122 ret = ((tmpscr->hidelayers >> indx) & 1) *10000;
9123 }
9124 break;
9125 }
9126 case SCREENDATASCRIPTDRAWS:
9127 {
9128 int32_t indx = ri->d[rINDEX] / 10000;
9129 if(indx < 0 || indx > 7 )
9130 {
9131 Z_scripterrlog("Invalid Index passed to Screen->HideScriptLayer[]: %d\n", indx);
9132 ret = 0;
9133 }
9134 else
9135 {
9136 ret = ((tmpscr->hidescriptlayers >> indx) & 1) ? 0 : 10000;
9137 }
9138 break;
9139 }
9140 case SCREENDATATIMEDWARPTICS: GET_SCREENDATA_VAR_INT32(timedwarptics, "TimedWarpTimer"); break; //W
9141 case SCREENDATANEXTMAP: GET_SCREENDATA_VAR_BYTE(nextmap, "NextMap"); break; //B
9142 case SCREENDATANEXTSCREEN: GET_SCREENDATA_VAR_BYTE(nextscr, "NextScreen"); break; //B
9143 109824 case SCREENDATASECRETCOMBO: GET_SCREENDATA_VAR_INDEX32(secretcombo, "SecretCombo", 127); break; //W, 128 OF THESE
9144 case SCREENDATASECRETCSET: GET_SCREENDATA_BYTE_INDEX(secretcset, "SecretCSet", 127); break; //B, 128 OF THESE
9145 case SCREENDATASECRETFLAG: GET_SCREENDATA_BYTE_INDEX(secretflag, "SecretFlags", 127); break; //B, 128 OF THESE
9146 case SCREENDATAVIEWX: break;//GET_SCREENDATA_VAR_INT32(viewX, "ViewX"); break; //W
9147 case SCREENDATAVIEWY: break;//GET_SCREENDATA_VAR_INT32(viewY, "ViewY"); break; //W
9148 case SCREENDATASCREENWIDTH: break;//GET_SCREENDATA_VAR_BYTE(scrWidth, "Width"); break; //B
9149 case SCREENDATASCREENHEIGHT: break;//GET_SCREENDATA_VAR_BYTE(scrHeight, "Height"); break; //B
9150 case SCREENDATAENTRYX: GET_SCREENDATA_VAR_BYTE(entry_x, "EntryX"); break; //B
9151 case SCREENDATAENTRYY: GET_SCREENDATA_VAR_BYTE(entry_y, "EntryY"); break; //B
9152 //Number of ffcs that are in use (have valid data
9153 case SCREENDATANUMFF:
9154 {
9155 uint32_t indx = ri->d[rINDEX] / 10000;
9156 if (!indx || indx > MAXFFCS)
9157 {
9158 Z_scripterrlog("Invalid Index passed to Screen->NumFFCs[%d].\n Valid indices are 1 through %d.\n", indx, MAXFFCS);
9159 ret = 0;
9160 }
9161 else
9162 {
9163 --indx;
9164 ret = (tmpscr->ffcs[indx].getData() != 0) ? 10000 : 0;
9165 }
9166 break;
9167 }
9168 //inita //INT32, 32 OF THESE, EACH WITH 2
9169 case SCREENDATAFFINITIALISED: {
9170 int32_t indx = ri->d[rINDEX] / 10000;
9171 if (indx < 0 || indx > MAXFFCS-1)
9172 {
9173 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", indx, "FFCRunning");
9174 ret = -10000;
9175 }
9176 else
9177 {
9178 ret = get_script_engine_data(ScriptType::FFC, indx).initialized ? 10000 : 0;
9179 }
9180 }
9181 break;
9182
9183 case SCREENDATASCRIPTENTRY: GET_SCREENDATA_VAR_INT32(script_entry, "ScriptEntry"); break; //W
9184 case SCREENDATASCRIPTOCCUPANCY: GET_SCREENDATA_VAR_INT32(script_occupancy, "ScriptOccupancy"); break;//W
9185 case SCREENDATASCRIPTEXIT: GET_SCREENDATA_VAR_INT32(script_exit, "ExitScript"); break; //W
9186 case SCREENDATAOCEANSFX: GET_SCREENDATA_VAR_BYTE(oceansfx, "OceanSFX"); break; //B
9187 case SCREENDATABOSSSFX: GET_SCREENDATA_VAR_BYTE(bosssfx, "BossSFX"); break; //B
9188 1 case SCREENDATASECRETSFX: GET_SCREENDATA_VAR_BYTE(secretsfx, "SecretSFX"); break; //B
9189 case SCREENDATAHOLDUPSFX: GET_SCREENDATA_VAR_BYTE(holdupsfx, "ItemSFX"); break; //B
9190 case SCREENDATASCREENMIDI:
9191 {
9192 ret = ((tmpscr->screen_midi+(MIDIOFFSET_MAPSCR-MIDIOFFSET_ZSCRIPT)) *10000);
9193 break;
9194 }
9195 case SCREENDATALENSLAYER: GET_SCREENDATA_VAR_BYTE(lens_layer, "LensLayer"); break; //B, OLD QUESTS ONLY?
9196
9197 case SCREENSIDEWARPID:
9198 {
9199 int32_t indx = ri->d[rINDEX] / 10000;
9200
9201 ret = (((tmpscr->flags2 >> indx) & 1)
9202 ? (tmpscr->sidewarpindex >> (2*indx)) & 3 //Return which warp is set
9203 : -1 //Returns -1 if no warp is set
9204 )*10000;
9205 break;
9206 }
9207
9208 case SCREENDATATILEWARPOVFLAGS:
9209 {
9210 int32_t indx = ri->d[rINDEX] / 10000;
9211 if ( ((unsigned)indx) > 3 )
9212 {
9213 Z_scripterrlog("Invalid index passed to TileWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
9214 ret = 0;
9215 }
9216 else
9217 {
9218 ret = (tmpscr->tilewarpoverlayflags & (1<<indx))?10000:0;
9219 }
9220 break;
9221 }
9222
9223 case SCREENDATASIDEWARPOVFLAGS:
9224 {
9225 int32_t indx = ri->d[rINDEX] / 10000;
9226 if ( ((unsigned)indx) > 3 )
9227 {
9228 Z_scripterrlog("Invalid index passed to SideWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
9229 ret = 0;
9230 }
9231 else
9232 {
9233 ret = (tmpscr->sidewarpoverlayflags & (1<<indx))?10000:0;
9234 }
9235 break;
9236 }
9237
9238 case SCREENDATATWARPRETSQR:
9239 {
9240 int32_t indx = ri->d[rINDEX] / 10000;
9241 if ( ((unsigned)indx) > 3)
9242 {
9243 ret = -10000;
9244 Z_scripterrlog("Invalid Array Index passed to Screen->TileWarpReturnSquare[]: %d\n", indx);
9245
9246 }
9247 else
9248 {
9249 ret = ((tmpscr->warpreturnc>>(indx*2))&3) * 10000;
9250 }
9251 break;
9252 }
9253
9254
9255 case SCREENDATASWARPRETSQR:
9256 {
9257 int32_t indx = ri->d[rINDEX] / 10000;
9258 if ( ((unsigned)indx) > 3)
9259 {
9260 ret = -10000;
9261 Z_scripterrlog("Invalid Array Index passed to Screen->SideWarpReturnSquare[]: %d\n", indx);
9262
9263 }
9264 else
9265 {
9266 ret = ((tmpscr->warpreturnc>>(8+(indx*2)))&3) * 10000;
9267 }
9268 break;
9269 }
9270
9271 case SCREENDATAFLAGS:
9272 {
9273 int32_t flagid = (ri->d[rINDEX])/10000;
9274 //bool valtrue = ( value ? 10000 : 0);
9275 switch(flagid)
9276 {
9277 case 0: ret = (tmpscr->flags * 10000); break;
9278 case 1: ret = (tmpscr->flags2 * 10000); break;
9279 case 2: ret = (tmpscr->flags3 * 10000); break;
9280 case 3: ret = (tmpscr->flags4 * 10000); break;
9281 case 4: ret = (tmpscr->flags5 * 10000); break;
9282 case 5: ret = (tmpscr->flags6 * 10000); break;
9283 case 6: ret = (tmpscr->flags7 * 10000); break;
9284 case 7: ret = (tmpscr->flags8 * 10000); break;
9285 case 8: ret = (tmpscr->flags9 * 10000); break;
9286 case 9: ret = (tmpscr->flags10 * 10000); break;
9287 default:
9288 {
9289 Z_scripterrlog("Invalid index passed to mapdata->flags[]: %d\n", flagid);
9290 ret = -10000;
9291 break;
9292
9293 }
9294 }
9295 break;
9296 //GET_SCREENDATA_BYTE_INDEX //B, 11 OF THESE, flags, flags2-flags10
9297 }
9298
9299 case SCREENSECRETSTRIGGERED:
9300 {
9301 910 ret = triggered_screen_secrets ? 10000L : 0L;
9302 910 break;
9303 }
9304
9305 case SHOWNMSG:
9306 {
9307 ret = ((msg_active || msg_onscreen) ? msgstr : 0) * 10000L;
9308 break;
9309 }
9310
9311 case SDD:
9312 {
9313
2/2
✓ Branch 0 taken 387442 times.
✓ Branch 1 taken 2580 times.
390022 int32_t di = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
9314 390022 ret=FFScript::get_screen_d(di, ri->d[rINDEX]/10000);
9315 }
9316 390022 break;
9317
9318 case SDDD:
9319 43250 ret=FFScript::get_screen_d((ri->d[rINDEX])/10000 + ((get_currdmap())<<7), ri->d[rINDEX2] / 10000);
9320 43250 break;
9321
9322 case LINKOTILE:
9323 ret=FFCore.getHeroOTile(ri->d[rINDEX]/10000, ri->d[rINDEX2] / 10000);
9324 break;
9325
9326 case SDDDD:
9327 3 ret=FFScript::get_screen_d(ri->d[rINDEX2] / 10000 + ((ri->d[rINDEX]/10000)<<7), ri->d[rEXP1] / 10000);
9328 3 break;
9329
9330 case SCRDOORD:
9331 4 ret=tmpscr->door[ri->d[rINDEX]/10000]*10000;
9332 4 break;
9333
9334 case SCREENSCRIPT:
9335 ret=tmpscr->script*10000;
9336 break;
9337
9338 case SCREENINITD:
9339 ret = tmpscr->screeninitd[ri->d[rINDEX]/10000];
9340 break;
9341
9342 case MAPDATAINITDARRAY:
9343 {
9344 if ( ri->mapsref == MAX_SIGNED_32 )
9345 {
9346 Z_scripterrlog("Script attempted to use a mapdata->InitD[%d] on a pointer that is uninitialised\n",ri->d[rINDEX]/10000);
9347 break;
9348 }
9349 else
9350 {
9351 mapscr *m = GetMapscr(ri->mapsref);
9352 ret = m->screeninitd[ri->d[rINDEX]/10000];
9353 }
9354 break;
9355 }
9356
9357 case MAPDATALAYERINVIS:
9358 {
9359 int32_t indx = ri->d[rINDEX] / 10000;
9360 if(indx < 0 || indx > 6 )
9361 {
9362 Z_scripterrlog("Invalid Index passed to mapdata->LayerInvisible[]: %d\n", indx);
9363 ret = 0;
9364 }
9365 else
9366 {
9367 if ( ri->mapsref == MAX_SIGNED_32 )
9368 {
9369 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","LayerInvisible");
9370 ret = -10000;
9371 }
9372 else
9373 {
9374 mapscr *m = GetMapscr(ri->mapsref);
9375 ret = ((m->hidelayers >> indx) & 1) *10000;
9376 }
9377 }
9378 break;
9379 }
9380 case MAPDATASCRIPTDRAWS:
9381 {
9382 int32_t indx = ri->d[rINDEX] / 10000;
9383 if(indx < 0 || indx > 7 )
9384 {
9385 Z_scripterrlog("Invalid Index passed to mapdata->DisableScriptDraws[]: %d\n", indx);
9386 ret = 0;
9387 }
9388 else
9389 {
9390 if ( ri->mapsref == MAX_SIGNED_32 )
9391 {
9392 Z_scripterrlog("Script attempted to use a mapdata->DisableScriptDraws on a pointer that is uninitialised\n");
9393 ret = -10000;
9394 }
9395 else
9396 {
9397 mapscr *m = GetMapscr(ri->mapsref);
9398 ret = ((m->hidescriptlayers >> indx) & 1) ? 0 : 10000;
9399 }
9400 }
9401 break;
9402 }
9403
9404 //These use the same method as GetScreenD -Z
9405 case SCREENWIDTH:
9406 // ret=FFScript::get_screenWidth(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9407 break;
9408
9409 case SCREENHEIGHT:
9410 // ret=FFScript::get_screenHeight(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9411 break;
9412
9413 case SCREENVIEWX:
9414 // ret=get_screenViewX(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9415 break;
9416
9417 case SCREENVIEWY:
9418 // ret=get_screenViewY(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9419 break;
9420
9421 case SCREENGUY:
9422 ret=get_screenGuy(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9423 break;
9424
9425 case SCREENSTRING:
9426 ret=get_screenString(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9427 break;
9428
9429 case SCREENROOM:
9430 ret=get_screenRoomtype(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9431 break;
9432
9433 case SCREENENTX:
9434 ret=get_screenEntryX(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9435 break;
9436
9437 case SCREENENTY:
9438 ret=get_screenEntryY(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9439 break;
9440
9441 case SCREENITEM:
9442 ret=get_screenitem(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9443 break;
9444
9445 case SCREENUNDCMB:
9446 ret=get_screenundercombo(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9447 break;
9448
9449 case SCREENUNDCST:
9450 ret=get_screenundercset(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9451 break;
9452
9453 case SCREENCATCH:
9454 ret=get_screenatchall(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9455 break;
9456
9457
9458 case LIT:
9459 10246 ret= darkroom ? 0 : 10000;
9460 10246 break;
9461
9462 case WAVY:
9463 7214 ret = wavy*10000;
9464 7214 break;
9465
9466 case QUAKE:
9467 2272 ret = quakeclk*10000;
9468 2272 break;
9469
9470 case SCREENFLAGSD:
9471 6637837 ret = get_screenflags(tmpscr,vbound(ri->d[rINDEX] / 10000,0,9));
9472 6637837 break;
9473
9474 case SCREENEFLAGSD:
9475 1522704 ret = get_screeneflags(tmpscr,vbound(ri->d[rINDEX] / 10000,0,2));
9476 1522704 break;
9477
9478 case NPCCOUNT:
9479 11316803 ret = guys.Count()*10000;
9480 11316803 break;
9481
9482 case ROOMDATA:
9483 ret = tmpscr->catchall*10000;
9484 break;
9485
9486 case ROOMTYPE:
9487 ret = tmpscr->room*10000;
9488 break;
9489
9490 case PUSHBLOCKX:
9491
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 229787 times.
229939 ret = blockmoving ? int32_t(mblock2.x)*10000 : -10000;
9492 229939 break;
9493
9494 case PUSHBLOCKY:
9495
1/2
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
91 ret = blockmoving ? int32_t(mblock2.y)*10000 : -10000;
9496 91 break;
9497
9498 case PUSHBLOCKLAYER:
9499 ret = blockmoving ? int32_t(mblock2.blockLayer)*10000 : -10000;
9500 break;
9501
9502 case PUSHBLOCKCOMBO:
9503 ret = mblock2.bcombo*10000;
9504 break;
9505
9506 case PUSHBLOCKCSET:
9507 ret = mblock2.cs*10000;
9508 break;
9509
9510 case UNDERCOMBO:
9511 1 ret = tmpscr->undercombo*10000;
9512 1 break;
9513
9514 case UNDERCSET:
9515 1 ret = tmpscr->undercset*10000;
9516 1 break;
9517
9518 //Creates an lweapon using an iemdata struct values to generate its properties.
9519 //Useful in conjunction with the new weapon editor.
9520 case CREATELWPNDX:
9521 {
9522 //Z_message("Trying to get Player->SetExtend().\n");
9523 int32_t ID = (ri->d[rINDEX] / 10000);
9524 int32_t itemid = (ri->d[rINDEX2]/10000);
9525 itemid = vbound(itemid,0,(MAXITEMS-1));
9526
9527 //Z_scripterrlog("GetHeroExtend rid->[2] is (%i), trying to use for '%s'\n", ri->d[rEXP1], "ri->d[rEXP1]");
9528 //Z_scripterrlog("GetHeroExtend rid->[1] is (%i), trying to use for '%s'\n", state, "state");
9529 //Z_scripterrlog("GetHeroExtend rid->[0] is (%i), trying to use for '%s'\n", dir, "dir");
9530 if ( Lwpns.Count() < 256 )
9531 {
9532
9533 Lwpns.add
9534 (
9535 new weapon
9536 (
9537 (zfix)0, /*X*/
9538 (zfix)0, /*Y*/
9539 (zfix)0, /*Z*/
9540 ID, /*id*/
9541 0, /*type*/
9542 0, /*power*/
9543 0, /*dir*/
9544 -1, /*Parentid*/
9545 Hero.getUID(), /*prntid*/
9546 false, /*isdummy*/
9547 1, /*script_gen*/
9548 1, /*islwpn*/
9549 (ID==wWind?1:0) /*special*/
9550 )
9551 );
9552 ri->lwpn = Lwpns.spr(Lwpns.Count() - 1)->getUID();
9553
9554 weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //last created
9555 //w->LOADGFX(FFCore.getDefWeaponSprite(ID)); //What the fuck Zoria, this broke old quests...
9556 w->ScriptGenerated = 1;
9557 w->isLWeapon = 1;
9558 if(ID == wWind) w->specialinfo = 1;
9559 //weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //last created
9560 //w->LOADGFX(FFCore.getDefWeaponSprite(ID)); //not needed here because this has access to wpn->prent
9561 }
9562 else
9563 {
9564 Z_scripterrlog("Tried to create too many LWeapons on the screen. The current LWeapon count is: %d\n", Lwpns.Count());
9565 ri->lwpn = 0;
9566 }
9567
9568 /* Z_scripterrlog("CreateLWeaponDx ri->d[rINDEX] is (%i), trying to use for '%s'\n", ID, "ID");
9569 Z_scripterrlog("CreateLWeaponDx ri->d[rINDEX2] is (%i), trying to use for '%s'\n", itemid, "itemid");
9570 Z_scripterrlog("CreateLWeaponDx ri->lwpn is (%i), trying to use for '%s'\n", ri->lwpn, "ri->lwpn"); */
9571
9572 ret = ri->lwpn;
9573 }
9574 break;
9575
9576 /*
9577 //Screen->CollisionDx(int32_t enemy_index, int32_t lweapon_type, int32_t power, int32_t x, int32_t y, int32_t weapon_dir, int32_t parent_item);
9578 //Handles collision between an npc at screen index 'enemy_index', and an arbitrary lweapon that may or may not exist.
9579 //Does damage, and returns true a value collision is valid. Returns a different value otherwise.
9580
9581 // take damage or ignore it
9582 // -1: damage (if any) dealt
9583 // 1: blocked
9584 // 0: weapon passes through unhindered
9585 // 2: heal enemy? -ZoriaRPG
9586
9587 //THis function should automatically check for shields blocking the weapon, and calculate enemy defences.
9588 //In theory, scritped swords, and other melee weapons could use this, as coudl any weapon, and it may simplify
9589 //collision routines.
9590 case COLLISIONDX:
9591 {
9592 //Z_message("Trying to get Player->SetExtend().\n");
9593 int32_t index = (ri->d[rINDEX] / 10000);
9594 int32_t lweapon_type = (ri->d[rINDEX2] / 10000);
9595 int32_t power = (ri->d[rEXP1]/10000);
9596
9597 int32_t wpnx = ri->4[3]/10000, wpny = ri->d[rSFRAME]/10000;
9598 int32_t dir = ri->d[rNUL]/10000;
9599 int32_t parentitem = (ri->d[rSFTEMP]/10000);
9600 lweapon_type = vbound(lweapon_type,0,40); //Are we at 40, or higher now>
9601 parentitem = vbound(itemid,0,255);
9602
9603 //Log the stack events:
9604 Z_scripterrlog("CollisionDx ri->d[rINDEX] is (%i), trying to use for '%s'\n", index, "index");
9605 Z_scripterrlog("CollisionDx ri->d[rINDEX2] is (%i), trying to use for '%s'\n", lweapon_type, "lweapon_type");
9606 Z_scripterrlog("CollisionDx ri->d[rEXP1] is (%i), trying to use for '%s'\n", power, "power");
9607 Z_scripterrlog("CollisionDx ri->d[rEXP2] is (%i), trying to use for '%s'\n", wpnx, "wpnx");
9608 Z_scripterrlog("CollisionDx ri->d[rSFRAME] is (%i), trying to use for '%s'\n", wpny, "wpny");
9609 Z_scripterrlog("CollisionDx ri->d[rNUL] is (%i), trying to use for '%s'\n", dir, "dir");
9610 Z_scripterrlog("CollisionDx ri->d[rINDEX] is (%i), trying to use for '%s'\n", parentitem, "parentitem");
9611
9612 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,lweapon_type,0,power,dir,parentitem,-1,false);
9613 int32_t retval = ((enemy*)guys.spr(index))->takehit(w);
9614 //TakeHit, as I recall, applies damage and returns the hit status. Gold.
9615 delete w;
9616 ret = retval;
9617 }
9618 break;
9619
9620 */
9621 case DEBUGREFFFC:
9622 {
9623 int32_t r = -1;
9624 if ( ri->ffcref ) r = ri->ffcref;
9625 ret = r * 10000;
9626 break;
9627 }
9628
9629 case DEBUGREFITEM:
9630 {
9631 int32_t r = -1;
9632 if ( ri->itemref ) r = ri->itemref;
9633 ret = r * 10000;
9634 break;
9635 }
9636
9637 case DEBUGREFITEMDATA:
9638 {
9639 int32_t r = -1;
9640 if ( ri->idata ) r = ri->idata;
9641 ret = r * 10000;
9642 break;
9643 }
9644
9645 case DEBUGREFLWEAPON:
9646 {
9647 int32_t r = -1;
9648 if ( ri->lwpn ) r = ri->lwpn;
9649 ret = r * 10000;
9650 break;
9651 }
9652
9653 case DEBUGREFEWEAPON:
9654 {
9655 int32_t r = -1;
9656 if ( ri->ewpn ) r = ri->ewpn;
9657 ret = r * 10000;
9658 break;
9659 }
9660
9661 case DEBUGREFNPC:
9662 {
9663 int32_t r = -1;
9664 if ( ri->guyref ) r = ri->guyref;
9665 ret = r * 10000;
9666 break;
9667 }
9668
9669 case DEBUGSP:
9670 {
9671 ret = SH::read_stack(ri->sp) * 10000;
9672 break;
9673 }
9674 case DEBUGGDR:
9675 {
9676 int32_t a = vbound(ri->d[rINDEX]/10000,0,15);
9677 int32_t r = -1;
9678 if ( game->global_d[a] ) r = game->global_d[a];
9679 ret = r * 10000;
9680 break;
9681 }
9682
9683 ///----------------------------------------------------------------------------------------------------//
9684 //New Datatype Variables
9685
9686 ///----------------------------------------------------------------------------------------------------//
9687 //spritedata sp-> Variables
9688
9689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 case SPRITEDATATILE: GET_SPRITEDATA_VAR_INT(tile, "Tile") break;
9690 case SPRITEDATAMISC: GET_SPRITEDATA_VAR_INT(misc, "Misc") break;
9691 case SPRITEDATACSETS:
9692 {
9693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
9694 {
9695 ret = -10000;
9696 Z_scripterrlog("Invalid Sprite ID passed to spritedata->CSet: %d\n", (ri->spritesref*10000));
9697 }
9698 else
9699 16 ret = ((wpnsbuf[ri->spritesref].csets & 0xF) * 10000);
9700 16 break;
9701 }
9702 case SPRITEDATAFLCSET:
9703 {
9704 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
9705 {
9706 ret = -10000;
9707 Z_scripterrlog("Invalid Sprite ID passed to spritedata->%s: %d\n", (ri->spritesref*10000), "FlashCSet");
9708 break;
9709 }
9710 ret = (((wpnsbuf[ri->spritesref].csets & 0xF0)>>4) * 10000);
9711 break;
9712 }
9713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 case SPRITEDATAFRAMES: GET_SPRITEDATA_VAR_INT(frames, "Frames") break;
9714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 case SPRITEDATASPEED: GET_SPRITEDATA_VAR_INT(speed, "Speed") break;
9715 case SPRITEDATATYPE: GET_SPRITEDATA_VAR_INT(type, "Type") break;
9716 case SPRITEDATAFLAGS:
9717 {
9718 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
9719 {
9720 ret = 0;
9721 Z_scripterrlog("Invalid Sprite ID passed to spritedata->Flags[]: %d\n", (ri->spritesref*10000));
9722 break;
9723 }
9724 int32_t index = ri->d[rINDEX]/10000;
9725 if(unsigned(index) >= 5)
9726 {
9727 ret = 0;
9728 Z_scripterrlog("Invalid index passed to spritedata->Flags[]: %d\n", index);
9729 break;
9730 }
9731 ret = (wpnsbuf[ri->spritesref].misc & (1<<index)) ? 10000 : 0;
9732 break;
9733 }
9734 case SPRITEDATAID:
9735 {
9736 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
9737 {
9738 ret = -10000;
9739 Z_scripterrlog("Invalid Sprite ID passed to spritedata->ID: %d\n", (ri->spritesref*10000));
9740 break;
9741 }
9742 ret = ri->spritesref*10000;
9743 break;
9744 }
9745
9746 ///----------------------------------------------------------------------------------------------------//
9747 //mapdata m-> variables
9748 #define GET_MAPDATA_VAR_INT32(member, str) \
9749 { \
9750 if ( mapscr *m = GetMapscr(ri->mapsref) ) \
9751 { \
9752 ret = (m->member *10000); \
9753 } \
9754 else \
9755 { \
9756 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9757 ret = -10000; \
9758 } \
9759 } \
9760
9761 #define GET_MAPDATA_VAR_INT16(member, str) \
9762 { \
9763 if ( mapscr *m = GetMapscr(ri->mapsref) ) \
9764 { \
9765 ret = (m->member *10000); \
9766 } \
9767 else \
9768 { \
9769 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9770 ret = -10000; \
9771 } \
9772 } \
9773
9774 #define GET_MAPDATA_VAR_BYTE(member, str) \
9775 { \
9776 if ( mapscr *m = GetMapscr(ri->mapsref) ) \
9777 { \
9778 ret = (m->member *10000); \
9779 } \
9780 else \
9781 { \
9782 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9783 ret = -10000; \
9784 } \
9785 } \
9786
9787 #define GET_MAPDATA_VAR_INDEX32(member, str, indexbound) \
9788 { \
9789 int32_t indx = ri->d[rINDEX] / 10000; \
9790 if(indx < 0 || indx > indexbound ) \
9791 { \
9792 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
9793 ret = -10000; \
9794 } \
9795 else \
9796 { \
9797 if (mapscr *m = GetMapscr(ri->mapsref)) \
9798 { \
9799 ret = (m->member[indx] *10000); \
9800 } \
9801 else \
9802 { \
9803 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9804 ret = -10000; \
9805 } \
9806 } \
9807 } \
9808
9809 #define GET_MAPDATA_VAR_INDEX16(member, str, indexbound) \
9810 { \
9811 int32_t indx = ri->d[rINDEX] / 10000; \
9812 if(indx < 0 || indx > indexbound ) \
9813 { \
9814 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
9815 ret = -10000; \
9816 } \
9817 else \
9818 { \
9819 if (mapscr *m = GetMapscr(ri->mapsref)) \
9820 { \
9821 ret = (m->member[indx] *10000); \
9822 } \
9823 else \
9824 { \
9825 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9826 ret = -10000; \
9827 } \
9828 } \
9829 } \
9830
9831 #define GET_MAPDATA_BYTE_INDEX(member, str, indexbound) \
9832 { \
9833 int32_t indx = ri->d[rINDEX] / 10000; \
9834 if(indx < 0 || indx > indexbound ) \
9835 { \
9836 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
9837 ret = -10000; \
9838 } \
9839 else \
9840 { \
9841 if (mapscr *m = GetMapscr(ri->mapsref)) \
9842 { \
9843 ret = (m->member[indx] *10000); \
9844 } \
9845 else \
9846 { \
9847 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9848 ret = -10000; \
9849 } \
9850 } \
9851 } \
9852
9853 /*
9854 #define GET_MAPDATA_LAYER_INDEX(member, str, indexbound) \
9855 { \
9856 int32_t indx = ri->d[rINDEX] / 10000; \
9857 mapscr *m = GetMapscr(ri->mapsref); \
9858 if ( indx == 0 ) \
9859 { \
9860 \
9861 } \
9862 else \
9863 { \
9864 ret = (m->member[indx-1] *10000); \
9865 } \
9866 } \
9867 */
9868
9869 #define GET_MAPDATA_LAYER_INDEX(member, str, indexbound) \
9870 { \
9871 int32_t indx = ri->d[rINDEX] / 10000; \
9872 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
9873 if(indx < 1 || indx > indexbound ) \
9874 { \
9875 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
9876 ret = -10000; \
9877 } \
9878 else \
9879 { \
9880 if (mapscr *m = GetMapscr(ri->mapsref)) \
9881 { \
9882 ret = (m->member[indx-1] *10000); \
9883 } \
9884 else \
9885 { \
9886 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9887 ret = -10000; \
9888 } \
9889 } \
9890 } \
9891
9892 #define GET_MAPDATA_BOOL_INDEX(member, str, indexbound) \
9893 { \
9894 int32_t indx = ri->d[rINDEX] / 10000; \
9895 if(indx < 0 || indx > indexbound ) \
9896 { \
9897 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
9898 ret = -10000; \
9899 } \
9900 else \
9901 { \
9902 if (mapscr *m = GetMapscr(ri->mapsref)) \
9903 { \
9904 ret = (m->member[indx]?10000:0); \
9905 } \
9906 else \
9907 { \
9908 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9909 ret = -10000; \
9910 } \
9911 } \
9912 } \
9913
9914 #define GET_FFC_MAPDATA_BOOL_INDEX(member, str, indexbound) \
9915 { \
9916 int32_t indx = ri->d[rINDEX] / 10000; \
9917 if(indx < 0 || indx > indexbound ) \
9918 { \
9919 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
9920 ret = -10000; \
9921 } \
9922 else \
9923 { \
9924 if (mapscr *m = GetMapscr(ri->mapsref)) \
9925 { \
9926 ret = (m->ffcs[indx].member?10000:0); \
9927 } \
9928 else \
9929 { \
9930 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9931 ret = -10000; \
9932 } \
9933 } \
9934 } \
9935
9936 #define GET_MAPDATA_FLAG(member, str) \
9937 { \
9938 int32_t flag = (value/10000); \
9939 if (mapscr *m = GetMapscr(ri->mapsref)) \
9940 { \
9941 ret = (m->member&flag) ? 10000 : 0); \
9942 } \
9943 else \
9944 { \
9945 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9946 ret = -10000; \
9947 } \
9948 } \
9949
9950 #define GET_SCREENDATA_COMBO_VAR(member, str) \
9951 { \
9952 if (mapscr *m = GetMapscr(ri->mapsref)) \
9953 { \
9954 int32_t pos = ri->d[rINDEX] / 10000; \
9955 if(BC::checkComboPos(pos, str) != SH::_NoError) \
9956 ret = -10000; \
9957 else \
9958 ret = m->member[pos]*10000; \
9959 } \
9960 else \
9961 { \
9962 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9963 ret = -10000; \
9964 } \
9965 } \
9966
9967 #define GET_MAPDATA_COMBO_VAR_BUF(member, str) \
9968 { \
9969 if (mapscr *m = GetMapscr(ri->mapsref)) \
9970 { \
9971 int32_t pos = ri->d[rINDEX] / 10000; \
9972 if(BC::checkComboPos(pos, str) != SH::_NoError) \
9973 ret = -10000; \
9974 else \
9975 ret = combobuf[m->data[pos]].member * 10000; \
9976 } \
9977 else \
9978 { \
9979 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9980 ret = -10000; \
9981 } \
9982 } \
9983
9984 #define GET_MAPDATA_FFCPOS_INDEX32(member, str, indexbound) \
9985 { \
9986 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
9987 if(indx < 0 || indx > indexbound ) \
9988 { \
9989 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
9990 ret = -10000; \
9991 } \
9992 else if (mapscr *m = GetMapscr(ri->mapsref)) \
9993 { \
9994 ret = (m->ffcs[indx].member).getZLong(); \
9995 } \
9996 else \
9997 { \
9998 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
9999 ret = -10000; \
10000 } \
10001 } \
10002
10003 #define GET_MAPDATA_FFC_INDEX32(member, str, indexbound) \
10004 { \
10005 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
10006 if(indx < 0 || indx > indexbound ) \
10007 { \
10008 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
10009 ret = -10000; \
10010 } \
10011 else if (mapscr *m = GetMapscr(ri->mapsref)) \
10012 { \
10013 ret = (m->ffcs[indx].member)*10000; \
10014 } \
10015 else \
10016 { \
10017 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
10018 ret = -10000; \
10019 } \
10020 } \
10021
10022 #define GET_MAPDATA_FFC_INDEX32(member, str, indexbound) \
10023 { \
10024 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
10025 if(indx < 0 || indx > indexbound ) \
10026 { \
10027 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
10028 ret = -10000; \
10029 } \
10030 else if (mapscr *m = GetMapscr(ri->mapsref)) \
10031 { \
10032 ret = (m->ffcs[indx].member)*10000; \
10033 } \
10034 else \
10035 { \
10036 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
10037 ret = -10000; \
10038 } \
10039 } \
10040
10041 case LOADMAPDATA:
10042 6554876 ret=FFScript::loadMapData();
10043 6554876 break;
10044
10045 case NPCCOLLISION:
10046 ret=FFCore.npc_collision();
10047 break;
10048
10049 case NPCLINEDUP:
10050 ret=FFCore.npc_linedup();
10051 break;
10052
10053 case CREATEBITMAP:
10054 {
10055 3670 ret=FFCore.do_create_bitmap();
10056 3670 break;
10057 }
10058
10059
10060
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 case MAPDATAVALID: GET_MAPDATA_VAR_BYTE(valid, "Valid"); break; //b
10061 case MAPDATAGUY: GET_MAPDATA_VAR_BYTE(guy, "Guy"); break; //b
10062 case MAPDATASTRING: GET_MAPDATA_VAR_INT32(str, "String"); break; //w
10063 case MAPDATAROOM: GET_MAPDATA_VAR_BYTE(room, "RoomType"); break; //b
10064 case MAPDATAITEM:
10065 {
10066 if ( mapscr *m = GetMapscr(ri->mapsref) )
10067 {
10068 if(m->hasitem)
10069 ret = (m->item *10000);
10070 else ret = -10000;
10071 }
10072 else
10073 {
10074 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Item"); \
10075 ret = -10000;
10076 }
10077 break;
10078 }
10079 case MAPDATAHASITEM: GET_MAPDATA_VAR_BYTE(hasitem, "HasItem"); break; //b
10080 case MAPDATATILEWARPTYPE: GET_MAPDATA_BYTE_INDEX(tilewarptype, "TileWarpType", 3); break; //b, 4 of these
10081 //case MAPDATATILEWARPOVFLAGS: GET_MAPDATA_VAR_BYTE(tilewarpoverlayflags, "TileWarpOverlayFlags"); break; //b, tilewarpoverlayflags
10082 case MAPDATADOORCOMBOSET: GET_MAPDATA_VAR_INT32(door_combo_set, "DoorComboSet"); break; //w
10083 case MAPDATAWARPRETX: GET_MAPDATA_BYTE_INDEX(warpreturnx, "WarpReturnX", 3); break; //b, 4 of these
10084 case MAPDATAWARPRETY: GET_MAPDATA_BYTE_INDEX(warpreturny, "WarpReturnY", 3); break; //b, 4 of these
10085 case MAPDATAWARPRETURNC: GET_MAPDATA_VAR_INT32(warpreturnc, "WarpReturnC"); break; //w
10086 case MAPDATASTAIRX: GET_MAPDATA_VAR_BYTE(stairx, "StairsX"); break; //b
10087 case MAPDATASTAIRY: GET_MAPDATA_VAR_BYTE(stairy, "StairsY"); break; //b
10088 case MAPDATAITEMX: GET_MAPDATA_VAR_BYTE(itemx, "ItemX"); break; //itemx
10089 case MAPDATAITEMY: GET_MAPDATA_VAR_BYTE(itemy, "ItemY"); break; //itemy
10090
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 case MAPDATACOLOUR: GET_MAPDATA_VAR_INT32(color, "CSet"); break; //w
10091 case MAPDATAENEMYFLAGS: GET_MAPDATA_VAR_BYTE(enemyflags, "EnemyFlags"); break; //b
10092 case MAPDATADOOR: GET_MAPDATA_BYTE_INDEX(door, "Door", 3); break; //b, 4 of these
10093 case MAPDATATILEWARPDMAP: GET_MAPDATA_VAR_INDEX32(tilewarpdmap, "TileWarpDMap", 3); break; //w, 4 of these
10094 case MAPDATATILEWARPSCREEN: GET_MAPDATA_BYTE_INDEX(tilewarpscr, "TileWarpScreen", 3); break; //b, 4 of these
10095 case MAPDATAEXITDIR: GET_MAPDATA_VAR_BYTE(exitdir, "ExitDir"); break; //b
10096 case MAPDATAENEMY: GET_MAPDATA_VAR_INDEX32(enemy, "Enemy", 9); break; //w, 10 of these
10097 case MAPDATAPATTERN: GET_MAPDATA_VAR_BYTE(pattern, "Pattern"); break; //b
10098 case MAPDATASIDEWARPTYPE: GET_MAPDATA_BYTE_INDEX(sidewarptype, "SideWarpType", 3); break; //b, 4 of these
10099 //case MAPDATASIDEWARPOVFLAGS: GET_MAPDATA_VAR_BYTE(sidewarpoverlayflags, "SideWarpOverlayFlags"); break; //b
10100 case MAPDATAWARPARRIVALX: GET_MAPDATA_VAR_BYTE(warparrivalx, "WarpArrivalX"); break; //b
10101 case MAPDATAWARPARRIVALY: GET_MAPDATA_VAR_BYTE(warparrivaly, "WarpArrivalY"); break; //b
10102 case MAPDATAPATH: GET_MAPDATA_BYTE_INDEX(path, "MazePath", 3); break; //b, 4 of these
10103 case MAPDATASIDEWARPSC: GET_MAPDATA_BYTE_INDEX(sidewarpscr, "SideWarpScreen", 3); break; //b, 4 of these
10104 case MAPDATAINITD: GET_MAPDATA_VAR_INDEX32(screeninitd, "InitD", 8); break; //w, 4 of these
10105 case MAPDATASIDEWARPDMAP: GET_MAPDATA_VAR_INDEX32(sidewarpdmap, "SideWarpDMap", 3); break; //w, 4 of these
10106 case MAPDATASIDEWARPINDEX: GET_MAPDATA_VAR_BYTE(sidewarpindex, "SideWarpIndex"); break; //b
10107 case MAPDATAUNDERCOMBO: GET_MAPDATA_VAR_INT32(undercombo, "UnderCombo"); break; //w
10108 case MAPDATAUNDERCSET: GET_MAPDATA_VAR_BYTE(undercset, "UnderCSet"); break; //b
10109 case MAPDATACATCHALL: GET_MAPDATA_VAR_INT32(catchall, "Catchall"); break; //W
10110
10111 case MAPDATACSENSITIVE: GET_MAPDATA_VAR_BYTE(csensitive, "CSensitive"); break; //B
10112 case MAPDATANORESET: GET_MAPDATA_VAR_INT32(noreset, "NoReset"); break; //W
10113 case MAPDATANOCARRY: GET_MAPDATA_VAR_INT32(nocarry, "NoCarry"); break; //W
10114
4/8
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 13 times.
✓ Branch 6 taken 13 times.
✗ Branch 7 not taken.
26 case MAPDATALAYERMAP: GET_MAPDATA_LAYER_INDEX(layermap, "LayerMap", 6); break; //B, 6 OF THESE
10115
4/8
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 13 times.
✓ Branch 6 taken 13 times.
✗ Branch 7 not taken.
26 case MAPDATALAYERSCREEN: GET_MAPDATA_LAYER_INDEX(layerscreen, "LayerScreen", 6); break; //B, 6 OF THESE
10116 case MAPDATALAYEROPACITY: GET_MAPDATA_LAYER_INDEX(layeropacity, "LayerOpacity", 6); break; //B, 6 OF THESE
10117 case MAPDATATIMEDWARPTICS: GET_MAPDATA_VAR_INT32(timedwarptics, "TimedWarpTimer"); break; //W
10118 case MAPDATANEXTMAP: GET_MAPDATA_VAR_BYTE(nextmap, "NextMap"); break; //B
10119 case MAPDATANEXTSCREEN: GET_MAPDATA_VAR_BYTE(nextscr, "NextScreen"); break; //B
10120
3/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✓ Branch 4 taken 128 times.
✗ Branch 5 not taken.
256 case MAPDATASECRETCOMBO: GET_MAPDATA_VAR_INDEX32(secretcombo, "SecretCombo", 127); break; //W, 128 OF THESE
10121
3/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✓ Branch 4 taken 128 times.
✗ Branch 5 not taken.
256 case MAPDATASECRETCSET: GET_MAPDATA_BYTE_INDEX(secretcset, "SecretCSet", 127); break; //B, 128 OF THESE
10122
3/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✓ Branch 4 taken 128 times.
✗ Branch 5 not taken.
256 case MAPDATASECRETFLAG: GET_MAPDATA_BYTE_INDEX(secretflag, "SecretFlags", 127); break; //B, 128 OF THESE
10123
10124 case MAPDATAVIEWX: break;//GET_MAPDATA_VAR_INT32(viewX, "ViewX"); break; //W
10125 case MAPDATASCRIPT: GET_MAPDATA_VAR_INT32(script, "Script"); break; //W
10126 case MAPDATAVIEWY: break;//GET_MAPDATA_VAR_INT32(viewY, "ViewY"); break; //W
10127 case MAPDATASCREENWIDTH: break;//GET_MAPDATA_VAR_BYTE(scrWidth, "Width"); break; //B
10128 case MAPDATASCREENHEIGHT: break;//GET_MAPDATA_VAR_BYTE(scrHeight, "Height"); break; //B
10129 case MAPDATAENTRYX: GET_MAPDATA_VAR_BYTE(entry_x, "EntryX"); break; //B
10130 case MAPDATAENTRYY: GET_MAPDATA_VAR_BYTE(entry_y, "EntryY"); break; //B
10131
3/6
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 200 times.
✓ Branch 4 taken 200 times.
✗ Branch 5 not taken.
400 case MAPDATAFFDATA: GET_MAPDATA_FFC_INDEX32(getData(), "FFCData", MAXFFCS-1); break; //W, MAXFFCS OF THESE
10132
3/6
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
16 case MAPDATAFFCSET: GET_MAPDATA_FFC_INDEX32(cset, "FFCCSet", MAXFFCS-1); break; //B, MAXFFCS
10133
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 case MAPDATAFFDELAY: GET_MAPDATA_FFC_INDEX32(delay, "FFCDelay", MAXFFCS-1); break; //W, MAXFFCS
10134
3/6
✓ Branch 0 taken 392 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 392 times.
✓ Branch 4 taken 392 times.
✗ Branch 5 not taken.
784 case MAPDATAFFX: GET_MAPDATA_FFCPOS_INDEX32(x, "FFCX", MAXFFCS-1); break; //INT32, MAXFFCS OF THESE
10135
3/6
✓ Branch 0 taken 392 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 392 times.
✓ Branch 4 taken 392 times.
✗ Branch 5 not taken.
784 case MAPDATAFFY: GET_MAPDATA_FFCPOS_INDEX32(y, "FFCY", MAXFFCS-1); break; //..
10136
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 case MAPDATAFFXDELTA: GET_MAPDATA_FFCPOS_INDEX32(vx, "FFCVx", MAXFFCS-1); break; //..
10137
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 case MAPDATAFFYDELTA: GET_MAPDATA_FFCPOS_INDEX32(vy, "FFCVy", MAXFFCS-1); break; //..
10138
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 case MAPDATAFFXDELTA2: GET_MAPDATA_FFCPOS_INDEX32(ax, "FFCAx", MAXFFCS-1); break; //..
10139
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 case MAPDATAFFYDELTA2: GET_MAPDATA_FFCPOS_INDEX32(ay, "FFCAy", MAXFFCS-1); break; //..
10140
3/6
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 91 times.
✓ Branch 4 taken 91 times.
✗ Branch 5 not taken.
182 case MAPDATAFFFLAGS: GET_MAPDATA_FFC_INDEX32(flags, "FFCFlags", MAXFFCS-1); break; //INT16, MAXFFCS OF THESE
10141 case MAPDATASIDEWARPID:
10142 {
10143 int32_t indx = ri->d[rINDEX] / 10000;
10144 if (mapscr *m = GetMapscr(ri->mapsref))
10145 {
10146 ret = (((m->flags2 >> indx) & 1)
10147 ? (m->sidewarpindex >> (2*indx)) & 3 //Return which warp is set
10148 : -1 //Returns -1 if no warp is set
10149 )*10000;
10150 }
10151 else
10152 {
10153 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","SideWarpID");
10154 ret = -10000;
10155 }
10156 break;
10157 }
10158 //Number of ffcs that are in use (have valid data
10159 case MAPDATANUMFF:
10160 {
10161 32 uint32_t indx = ri->d[rINDEX] / 10000;
10162
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
32 if (!indx || indx > MAXFFCS)
10163 {
10164 Z_scripterrlog("Invalid Index passed to mapdata->NumFFCs[%d].\n Valid indices are 1 through %d.\n", indx, MAXFFCS);
10165 ret = 0;
10166 }
10167
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 else if (mapscr *m = GetMapscr(ri->mapsref))
10168 {
10169 32 --indx;
10170 32 ret = (m->ffcs[indx].getData() != 0) ? 10000 : 0;
10171 32 }
10172 else
10173 {
10174 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","NumFFCs[]");
10175 ret = 0;
10176 }
10177 32 break;
10178 }
10179
10180 case MAPDATATILEWARPOVFLAGS:
10181 {
10182 int32_t indx = ri->d[rINDEX] / 10000;
10183 if ( ((unsigned)indx) > 3 )
10184 {
10185 Z_scripterrlog("Invalid index passed to TileWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
10186 ret = 0;
10187 }
10188 else if (mapscr *m = GetMapscr(ri->mapsref))
10189 {
10190 ret = (m->tilewarpoverlayflags & (1<<indx))?10000:0;
10191 }
10192 else
10193 {
10194 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","NumFFCs[]");
10195 ret = 0;
10196 }
10197 break;
10198 }
10199
10200 case MAPDATASIDEWARPOVFLAGS:
10201 {
10202 int32_t indx = ri->d[rINDEX] / 10000;
10203 if ( ((unsigned)indx) > 3 )
10204 {
10205 Z_scripterrlog("Invalid index passed to SideWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
10206 ret = 0;
10207 }
10208 else if (mapscr *m = GetMapscr(ri->mapsref))
10209 {
10210 ret = (m->sidewarpoverlayflags & (1<<indx))?10000:0;
10211 }
10212 else
10213 {
10214 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","NumFFCs[]");
10215 ret = 0;
10216 }
10217 break;
10218 }
10219
10220 case MAPDATATWARPRETSQR:
10221 {
10222 int32_t indx = ri->d[rINDEX] / 10000;
10223 if ( ((unsigned)indx) > 3)
10224 {
10225 ret = -10000;
10226 Z_scripterrlog("Invalid Array Index passed to mapdata->TileWarpReturnSquare[]: %d\n", indx);
10227
10228 }
10229 else if (mapscr *m = GetMapscr(ri->mapsref))
10230 {
10231 ret = ((m->warpreturnc>>(indx*2))&3) * 10000;
10232 }
10233 else
10234 {
10235 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str");
10236 ret = -10000;
10237 }
10238 break;
10239 }
10240
10241 case MAPDATASWARPRETSQR:
10242 {
10243 int32_t indx = ri->d[rINDEX] / 10000;
10244 if ( ((unsigned)indx) > 3)
10245 {
10246 ret = -10000;
10247 Z_scripterrlog("Invalid Array Index passed to mapdata->TileWarpReturnSquare[]: %d\n", indx);
10248
10249 }
10250 else if (mapscr *m = GetMapscr(ri->mapsref))
10251 {
10252 ret = ((m->warpreturnc>>(8+(indx*2)))&3) * 10000;
10253 }
10254 else
10255 {
10256 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str");
10257 ret = -10000;
10258 }
10259 break;
10260 }
10261
10262 case MAPDATAFFWIDTH:
10263 {
10264
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (mapscr *m = GetMapscr(ri->mapsref))
10265 {
10266 8 int32_t indx = (ri->d[rINDEX] / 10000)-1;
10267
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if ( indx < 0 || indx > MAXFFCS-1 )
10268 {
10269 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCTileWidth[]: %d\n", indx+1);
10270 ret = -10000;
10271 break;
10272 }
10273 8 ret=(m->ffTileWidth(indx))*10000;
10274 8 }
10275 else
10276 {
10277 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCTileWidth[]");
10278 ret = -10000;
10279 }
10280 8 break;
10281 }
10282
10283 case MAPDATAFFHEIGHT:
10284 {
10285
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (mapscr *m = GetMapscr(ri->mapsref))
10286 {
10287 8 int32_t indx = (ri->d[rINDEX] / 10000)-1;
10288
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if ( indx < 0 || indx > MAXFFCS-1 )
10289 {
10290 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCTileHeight[]: %d\n", indx+1);
10291 ret = -10000;
10292 break;
10293 }
10294 8 ret=(m->ffTileHeight(indx))*10000;
10295 8 }
10296 else
10297 {
10298 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCTileHeight[]");
10299 ret = -10000;
10300 }
10301 8 break;
10302
10303 }
10304
10305 case MAPDATAFFEFFECTWIDTH:
10306 {
10307
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (mapscr *m = GetMapscr(ri->mapsref))
10308 {
10309 5 int32_t indx = (ri->d[rINDEX] / 10000)-1;
10310
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if ( indx < 0 || indx > MAXFFCS-1 )
10311 {
10312 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCEffectWidth[]: %d\n", indx+1);
10313 ret = -10000;
10314 break;
10315 }
10316 5 ret=(m->ffEffectWidth(indx))*10000;
10317 5 }
10318 else
10319 {
10320 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCEffectWidth[]");
10321 ret = -10000;
10322 }
10323 5 break;
10324 }
10325
10326 case MAPDATAFFEFFECTHEIGHT:
10327 {
10328
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (mapscr *m = GetMapscr(ri->mapsref))
10329 {
10330 5 int32_t indx = (ri->d[rINDEX] / 10000)-1;
10331
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if ( indx < 0 || indx > MAXFFCS-1 )
10332 {
10333 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCEffectHeight[]: %d\n", indx+1);
10334 ret = -10000;
10335 break;
10336 }
10337 5 ret=(m->ffEffectHeight(indx))*10000;
10338 5 }
10339 else
10340 {
10341 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCEffectHeight[]");
10342 ret = -10000;
10343 }
10344 5 break;
10345 }
10346
10347
10348 case MAPDATAFFLINK: GET_MAPDATA_FFC_INDEX32(link, "FFCLink", MAXFFCS-1); break; //B, MAXFFCS OF THESE
10349
3/6
✓ Branch 0 taken 32773 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32773 times.
✓ Branch 4 taken 32773 times.
✗ Branch 5 not taken.
65546 case MAPDATAFFSCRIPT: GET_MAPDATA_FFC_INDEX32(script, "FFCScript", MAXFFCS-1); break; //W, MAXFFCS OF THESE
10350
10351 case MAPDATAINTID: //Same form as SetScreenD()
10352 //SetFFCInitD(ffindex, d, value)
10353 {
10354
1/2
✓ Branch 0 taken 1800 times.
✗ Branch 1 not taken.
1800 if (mapscr *m = GetMapscr(ri->mapsref))
10355 {
10356 1800 int32_t ffid = (ri->d[rINDEX]/10000) -1;
10357 1800 int32_t indx = ri->d[rINDEX2]/10000;
10358
10359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1800 times.
1800 if ( (unsigned)ffid > MAXFFCS-1 )
10360 {
10361 Z_scripterrlog("Invalid FFC id passed to mapdata->FFCInitD[]: %d",ffid);
10362 ret = -10000;
10363 }
10364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1800 times.
1800 else if ( (unsigned)indx > 7 )
10365 {
10366 Z_scripterrlog("Invalid InitD[] index passed to mapdata->FFCInitD[]: %d",indx);
10367 ret = -10000;
10368 }
10369 else
10370 {
10371 1800 ret = (m->ffcs[ffid].initd[indx]);
10372 }
10373
10374 //int32_t ffindex = ri->d[rINDEX]/10000;
10375 //int32_t d = ri->d[rINDEX2]/10000;
10376 //int32_t v = (value/10000);
10377 1800 }
10378 else
10379 {
10380 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","GetFFCInitD()");
10381 ret = -10000;
10382 }
10383 1800 break;
10384 }
10385
10386
10387
10388 //initd //INT32 , 32 OF THESE, EACH WITH 10 INDICES.
10389
10390 case MAPDATAINITA:
10391 //same form as SetScreenD
10392 {
10393 if (mapscr *m = GetMapscr(ri->mapsref))
10394 {
10395 //int32_t ffindex = ri->d[rINDEX]/10000;
10396 //int32_t d = ri->d[rINDEX2]/10000;
10397 //int32_t v = (value/10000);
10398
10399 int32_t ffid = (ri->d[rINDEX]/10000) -1;
10400 int32_t indx = ri->d[rINDEX2]/10000;
10401
10402 if ( (unsigned)ffid > MAXFFCS-1 )
10403 {
10404 Z_scripterrlog("Invalid FFC id passed to mapdata->FFCInitD[]: %d",ffid);
10405 ret = -10000;
10406 }
10407 else if ( (unsigned)indx > 1 )
10408 {
10409 Z_scripterrlog("Invalid InitD[] index passed to mapdata->FFCInitD[]: %d",indx);
10410 ret = -10000;
10411 }
10412 else
10413 {
10414 ret = (m->ffcs[ffid].inita[indx]);
10415 }
10416 }
10417 else
10418 {
10419 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","GetFFCInitD()");
10420 ret = -10000;
10421 }
10422 break;
10423 }
10424
10425 //inita //INT32, 32 OF THESE, EACH WITH 2
10426
10427 case MAPDATAFFINITIALISED:
10428 {
10429 int32_t indx = ri->d[rINDEX] / 10000;
10430 if (indx < 0 || indx > MAXFFCS-1)
10431 {
10432 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", "FFCRunning", indx);
10433 ret = -10000;
10434 }
10435 else
10436 {
10437 if (mapscr *m = GetMapscr(ri->mapsref))
10438 {
10439 ret = get_script_engine_data(ScriptType::FFC, indx).initialized ? 10000 : 0;
10440 }
10441 else
10442 {
10443 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n", "FFCRunning");
10444 ret = -10000;
10445 }
10446 }
10447 }
10448 break;
10449
10450 case MAPDATASCRIPTENTRY: GET_MAPDATA_VAR_INT32(script_entry, "ScriptEntry"); break; //W
10451 case MAPDATASCRIPTOCCUPANCY: GET_MAPDATA_VAR_INT32(script_occupancy, "ScriptOccupancy"); break;//W
10452 case MAPDATASCRIPTEXIT: GET_MAPDATA_VAR_INT32(script_exit, "ExitScript"); break; //W
10453 case MAPDATAOCEANSFX: GET_MAPDATA_VAR_BYTE(oceansfx, "OceanSFX"); break; //B
10454 case MAPDATABOSSSFX: GET_MAPDATA_VAR_BYTE(bosssfx, "BossSFX"); break; //B
10455 case MAPDATASECRETSFX: GET_MAPDATA_VAR_BYTE(secretsfx, "SecretSFX"); break; //B
10456 case MAPDATAHOLDUPSFX: GET_MAPDATA_VAR_BYTE(holdupsfx, "ItemSFX"); break; //B
10457 case MAPDATASCREENMIDI:
10458 {
10459 if (mapscr *m = GetMapscr(ri->mapsref))
10460 {
10461 ret = ((m->screen_midi+(MIDIOFFSET_MAPSCR-MIDIOFFSET_ZSCRIPT)) *10000);
10462 }
10463 else
10464 {
10465 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","MIDI");
10466 ret = -10000;
10467 }
10468 break;
10469 }
10470 case MAPDATALENSLAYER: GET_MAPDATA_VAR_BYTE(lens_layer, "LensLayer"); break; //B, OLD QUESTS ONLY?
10471 case MAPDATAMAP:
10472 {
10473
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if (mapscr *m = GetMapscr(ri->mapsref))
10474 {
10475 18 ret = getMap(ri->mapsref) * 10000;
10476 18 }
10477 else
10478 {
10479 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Map");
10480 ret = -10000;
10481 }
10482 18 break;
10483 }
10484 case MAPDATASCREEN:
10485 {
10486
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if (mapscr *m = GetMapscr(ri->mapsref))
10487 {
10488 42 ret = getScreen(ri->mapsref) * 10000;
10489 42 }
10490 else
10491 {
10492 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Screen");
10493 ret = -10000;
10494 }
10495 42 break;
10496 }
10497
10498 case MAPDATAFLAGS:
10499 {
10500
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(mapscr *m = GetMapscr(ri->mapsref))
10501 {
10502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if ( get_qr(qr_OLDMAPDATAFLAGS) )
10503 {
10504 ret = get_screenflags(m,vbound(ri->d[rINDEX] / 10000,0,9));
10505 }
10506 else
10507 {
10508 6 int32_t flagid = (ri->d[rINDEX])/10000;
10509 //bool valtrue = ( value ? 10000 : 0);
10510
1/11
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
6 switch(flagid)
10511 {
10512 case 0: ret = (m->flags * 10000); break;
10513 case 1: ret = (m->flags2 * 10000); break;
10514 case 2: ret = (m->flags3 * 10000); break;
10515 case 3: ret = (m->flags4 * 10000); break;
10516 case 4: ret = (m->flags5 * 10000); break;
10517 case 5: ret = (m->flags6 * 10000); break;
10518 6 case 6: ret = (m->flags7 * 10000); break;
10519 case 7: ret = (m->flags8 * 10000); break;
10520 case 8: ret = (m->flags9 * 10000); break;
10521 case 9: ret = (m->flags10 * 10000); break;
10522 default:
10523 {
10524 Z_scripterrlog("Invalid index passed to mapdata->flags[]: %d\n", flagid);
10525 ret = -10000;
10526 break;
10527
10528 }
10529 }
10530 }
10531 6 }
10532 else
10533 {
10534 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Flags[]");
10535 ret = -10000;
10536 }
10537
10538 6 break;
10539 //GET_MAPDATA_BYTE_INDEX //B, 11 OF THESE, flags, flags2-flags10
10540 }
10541
10542 case MAPDATAMISCD:
10543 {
10544 int32_t indx = (ri->d[rINDEX])/10000;
10545 int32_t mi = get_mi(ri->mapsref);
10546 if(unsigned(mi) >= MAX_MI)
10547 {
10548 ret = 0;
10549 break;
10550 }
10551 if( ((unsigned)indx) > 7 )
10552 {
10553 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", indx);
10554 ret = -10000;
10555 }
10556 else if (mapscr *m = GetMapscr(ri->mapsref))
10557 {
10558 ret = (game->screen_d[mi][indx]) * 10000;
10559 }
10560 else
10561 {
10562 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","D[]");
10563 ret = -10000;
10564 }
10565 break;
10566 }
10567
10568 case MAPDATACOMBODD:
10569 {
10570
1/2
✓ Branch 0 taken 4767952 times.
✗ Branch 1 not taken.
4767952 if (mapscr *m = GetMapscr(ri->mapsref))
10571 {
10572 4767952 int32_t pos = ri->d[rINDEX] / 10000;
10573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4767952 times.
4767952 if(BC::checkComboPos(pos, "mapdata->ComboD[pos]") != SH::_NoError)
10574 {
10575 ret = -10000;
10576 }
10577 else
10578 {
10579 4767952 ret = m->data[pos] * 10000;
10580 }
10581 4767952 }
10582 else
10583 {
10584 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboD[]",ri->mapsref);
10585 ret = -10000;
10586 }
10587 4767952 break;
10588 //GET_SCREENDATA_COMBO_VAR(data, "mapdata->ComboD") break;
10589 }
10590
10591 case MAPDATACOMBOCD:
10592 {
10593
1/2
✓ Branch 0 taken 4654485 times.
✗ Branch 1 not taken.
4654485 if (mapscr *m = GetMapscr(ri->mapsref))
10594 {
10595 //int32_t ffindex = ri->d[rINDEX]/10000;
10596 //int32_t d = ri->d[rINDEX2]/10000;
10597 //int32_t v = (value/10000);
10598 4654485 int32_t pos = ri->d[rINDEX] / 10000;
10599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4654485 times.
4654485 if(BC::checkComboPos(pos, "mapdata->ComboC[pos]") != SH::_NoError)
10600 {
10601 ret = -10000;
10602 }
10603 else
10604 {
10605 4654485 ret = m->cset[pos] * 10000;
10606 }
10607 4654485 }
10608 else
10609 {
10610 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboC[]",ri->mapsref);
10611 ret = -10000;
10612 }
10613 4654485 break;
10614 }
10615 //GET_SCREENDATA_COMBO_VAR(cset, "mapdata->ComboC") break;
10616
10617 case MAPDATACOMBOFD:
10618 {
10619
1/2
✓ Branch 0 taken 5945377 times.
✗ Branch 1 not taken.
5945377 if (mapscr *m = GetMapscr(ri->mapsref))
10620 {
10621 //int32_t ffindex = ri->d[rINDEX]/10000;
10622 //int32_t d = ri->d[rINDEX2]/10000;
10623 //int32_t v = (value/10000);
10624 5945377 int32_t pos = ri->d[rINDEX] / 10000;
10625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5945377 times.
5945377 if(BC::checkComboPos(pos, "mapdata->ComboF[pos]") != SH::_NoError)
10626 {
10627 ret = -10000;
10628 }
10629 else
10630 {
10631 5945377 ret = m->sflag[pos] * 10000;
10632 }
10633 5945377 }
10634 else
10635 {
10636 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboF[]",ri->mapsref);
10637 ret = -10000;
10638 }
10639 5945377 break;
10640 }
10641 //GET_SCREENDATA_COMBO_VAR(sflag, "mapdata->ComboF") break;
10642
10643
10644
10645 case MAPDATACOMBOTD:
10646 {
10647
1/2
✓ Branch 0 taken 2540907 times.
✗ Branch 1 not taken.
2540907 if (mapscr *m = GetMapscr(ri->mapsref))
10648 {
10649 //int32_t ffindex = ri->d[rINDEX]/10000;
10650 //int32_t d = ri->d[rINDEX2]/10000;
10651 //int32_t v = (value/10000);
10652 2540907 int32_t pos = ri->d[rINDEX] / 10000;
10653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2540907 times.
2540907 if(BC::checkComboPos(pos, "mapdata->ComboT[pos]") != SH::_NoError)
10654 {
10655 ret = -10000;
10656
10657 }
10658 else
10659 {
10660 2540907 ret = combobuf[m->data[pos]].type * 10000;
10661 }
10662 2540907 }
10663 else
10664 {
10665 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboT[]",ri->mapsref);
10666 ret = -10000;
10667 }
10668 2540907 break;
10669 }
10670 //GET_MAPDATA_COMBO_VAR_BUF(type, "mapdata->ComboT") break;
10671
10672 case MAPDATACOMBOID:
10673 {
10674
1/2
✓ Branch 0 taken 345816 times.
✗ Branch 1 not taken.
345816 if (mapscr *m = GetMapscr(ri->mapsref))
10675 {
10676 //int32_t ffindex = ri->d[rINDEX]/10000;
10677 //int32_t d = ri->d[rINDEX2]/10000;
10678 //int32_t v = (value/10000);
10679 345816 int32_t pos = ri->d[rINDEX] / 10000;
10680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 345816 times.
345816 if(BC::checkComboPos(pos, "mapdata->ComboI[pos]") != SH::_NoError)
10681 {
10682 ret = -10000;
10683 }
10684 else
10685 {
10686 345816 ret = combobuf[m->data[pos]].flag * 10000;
10687 }
10688 345816 }
10689 else
10690 {
10691 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboI[]",ri->mapsref);
10692 ret = -10000;
10693 }
10694 345816 break;
10695 //GET_SCREENDATA_COMBO_VAR(data, "mapdata->ComboD") break;
10696 }
10697 //GET_MAPDATA_COMBO_VAR_BUF(flag, "mapdata->ComboI") break;
10698
10699 case MAPDATACOMBOSD:
10700 {
10701
1/2
✓ Branch 0 taken 85947 times.
✗ Branch 1 not taken.
85947 if (mapscr *m = GetMapscr(ri->mapsref))
10702 {
10703 //int32_t ffindex = ri->d[rINDEX]/10000;
10704 //int32_t d = ri->d[rINDEX2]/10000;
10705 //int32_t v = (value/10000);
10706 85947 int32_t pos = ri->d[rINDEX] / 10000;
10707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85947 times.
85947 if(BC::checkComboPos(pos, "mapdata->ComboS[pos]") != SH::_NoError)
10708 {
10709 ret = -10000;
10710 }
10711 else
10712 {
10713 85947 ret = (combobuf[m->data[pos]].walk & 0xF) * 10000;
10714 }
10715 85947 }
10716 else
10717 {
10718 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboS[]", ri->mapsref);
10719 ret = -10000;
10720 }
10721 85947 break;
10722 }
10723
10724 case MAPDATACOMBOED:
10725 {
10726 if (mapscr *m = GetMapscr(ri->mapsref))
10727 {
10728 //int32_t ffindex = ri->d[rINDEX]/10000;
10729 //int32_t d = ri->d[rINDEX2]/10000;
10730 //int32_t v = (value/10000);
10731 int32_t pos = ri->d[rINDEX] / 10000;
10732 if(BC::checkComboPos(pos, "mapdata->ComboE[pos]") != SH::_NoError)
10733 {
10734 ret = -10000;
10735 }
10736 else
10737 {
10738 ret = ((combobuf[m->data[pos]].walk & 0xF0)>>4) * 10000;
10739 }
10740 }
10741 else
10742 {
10743 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboE[]", ri->mapsref);
10744 ret = -10000;
10745 }
10746 break;
10747 }
10748
10749 case MAPDATASCREENSTATED:
10750 {
10751
1/2
✓ Branch 0 taken 45056 times.
✗ Branch 1 not taken.
45056 if (mapscr *m = GetMapscr(ri->mapsref))
10752 {
10753 45056 int32_t mi = get_mi(ri->mapsref);
10754
1/2
✓ Branch 0 taken 45056 times.
✗ Branch 1 not taken.
45056 if(mi<0) {ret = 0;break;}
10755 45056 ret=((game->maps[mi]>>((ri->d[rINDEX]/10000)))&1)?10000:0;
10756 45056 }
10757 else
10758 {
10759 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","State[]", ri->mapsref);
10760 ret = 0;
10761 }
10762 45056 break;
10763 }
10764 case MAPDATAEXSTATED:
10765 {
10766 if (mapscr *m = GetMapscr(ri->mapsref))
10767 {
10768 int32_t mi = get_mi(ri->mapsref);
10769 if(mi<0) {ret = 0;break;}
10770 ret=((game->xstates[mi]>>((ri->d[rINDEX]/10000)))&1)?10000:0;
10771 }
10772 else
10773 {
10774 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","State[]", ri->mapsref);
10775 ret = 0;
10776 }
10777 break;
10778 }
10779 case MAPDATALENSSHOWS:
10780 {
10781 ret = 0;
10782 int ind = ri->d[rINDEX]/10000;
10783 if(ind < 0 || ind > 6)
10784 Z_scripterrlog("Bad index mapdata->LensShows[%d]\n",ind);
10785 else if(mapscr *m = GetMapscr(ri->mapsref))
10786 ret = (m->lens_show & (1<<ind)) ? 10000 : 0;
10787 else Z_scripterrlog("mapdata->LensShows[] pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
10788 break;
10789 }
10790 case MAPDATALENSHIDES:
10791 {
10792 ret = 0;
10793 int ind = ri->d[rINDEX]/10000;
10794 if(ind < 0 || ind > 6)
10795 Z_scripterrlog("Bad index mapdata->LensHides[%d]\n",ind);
10796 else if(mapscr *m = GetMapscr(ri->mapsref))
10797 ret = (m->lens_hide & (1<<ind)) ? 10000 : 0;
10798 else Z_scripterrlog("mapdata->LensHides[] pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
10799 break;
10800 }
10801 case MAPDATASCREENFLAGSD:
10802 {
10803 if(mapscr *m = GetMapscr(ri->mapsref))
10804 {
10805 ret = get_screenflags(m,vbound(ri->d[rINDEX] / 10000,0,9));
10806 }
10807 else
10808 {
10809 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","SFlags[]", ri->mapsref);
10810 ret = -10000;
10811 }
10812 break;
10813 }
10814
10815 case MAPDATASCREENEFLAGSD:
10816 {
10817 if(mapscr *m = GetMapscr(ri->mapsref))
10818 {
10819 ret = get_screeneflags(m,vbound(ri->d[rINDEX] / 10000,0,2));
10820 }
10821 else
10822 {
10823 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","EFlags[]", ri->mapsref);
10824 ret = -10000;
10825 }
10826 break;
10827 }
10828
10829 ///----------------------------------------------------------------------------------------------------//
10830 //shopdata sd-> variables
10831
10832 case SHOPDATATYPE:
10833 {
10834 int32_t ref = ri->shopsref;
10835 if ( ref > NUMINFOSHOPS || ref < 0 ) ret = 0;
10836 else ret = ( ( ref <= NUMSHOPS ) ? 10000 : 20000 );
10837 break;
10838 }
10839 case SHOPDATAITEM:
10840 {
10841
10842 int32_t ref = ri->shopsref;
10843 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
10844 int32_t indx = ri->d[rINDEX] / 10000;
10845 if ( indx < 0 || indx > 2 )
10846 {
10847 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "Item");
10848 ret = -10000;
10849 }
10850 else
10851 {
10852 if ( isInfo )
10853 {
10854 Z_scripterrlog("Attempted to load an 'item' from an infoshop, using shop ID: %d\n", ri->shopsref);
10855 ret = -10000;
10856 }
10857 else
10858 {
10859 ret = ((int32_t)(QMisc.shop[ref].item[indx]) * 10000);
10860 }
10861 }
10862 break;
10863 }
10864
10865
10866 // GET_SHOPDATA_VAR_INDEX(item, "Item", 2); break;
10867 case SHOPDATAHASITEM:
10868 {
10869
10870 int32_t ref = ri->shopsref;
10871 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
10872 int32_t indx = ri->d[rINDEX] / 10000;
10873 if ( indx < 0 || indx > 2 )
10874 {
10875 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "HasItem");
10876 ret = -10000;
10877 }
10878 else
10879 {
10880 if ( isInfo )
10881 {
10882 Z_scripterrlog("Attempted to load 'hasitem' from an infoshop, using shop ID: %d\n", ri->shopsref);
10883 ret = -10000;
10884 }
10885 else
10886 {
10887 ret = ((int32_t)(QMisc.shop[ref].hasitem[indx]) * 10000);
10888 }
10889 }
10890 break;
10891 }
10892
10893
10894 //GET_SHOPDATA_VAR_INDEX(hasitem, "HasItem", 2); break;
10895 case SHOPDATAPRICE:
10896 {
10897
10898 int32_t ref = ri->shopsref;
10899 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
10900 int32_t indx = ri->d[rINDEX] / 10000;
10901 if ( indx < 0 || indx > 2 )
10902 {
10903 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "Price");
10904 ret = -10000;
10905 }
10906 else
10907 {
10908 if ( isInfo )
10909 {
10910 ret = ((int32_t)(QMisc.info[ref].price[indx]) * 10000);
10911 }
10912 else
10913 {
10914 ret = ((int32_t)(QMisc.shop[ref].price[indx]) * 10000);
10915 }
10916 }
10917 break;
10918 }
10919
10920
10921 //GET_SHOPDATA_VAR_INDEX(price, "Price", 2); break;
10922 //Pay for info
10923 case SHOPDATASTRING:
10924 {
10925 if (((unsigned)ri->shopsref) > NUMINFOSHOPS)
10926 {
10927 Z_scripterrlog("Invalid shop pointer passed to shopdata->String[]: %d\n", ri->shopsref);
10928 ret = -10000;
10929 }
10930 else
10931 {
10932 int32_t ref = ri->shopsref;
10933 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
10934 int32_t indx = ri->d[rINDEX] / 10000;
10935 if ( indx < 0 || indx > 2 )
10936 {
10937 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "String");
10938 }
10939 else
10940 {
10941 if ( isInfo )
10942 {
10943 ret = ((int32_t)(QMisc.info[ref].str[indx]) * 10000);
10944 }
10945 else
10946 {
10947 ret = ((int32_t)(QMisc.shop[ref].str[indx]) * 10000);
10948 }
10949 }
10950
10951
10952 }
10953
10954 //GET_SHOPDATA_VAR_INDEX(str, String, 2); break;
10955 break;
10956 }
10957
10958
10959 ///----------------------------------------------------------------------------------------------------//
10960 //dmapdata dmd-> variables
10961
10962 //getter
10963 701 case DMAPDATAID: ret = ri->dmapsref*10000; break; //read-only, equal to CurrentDMap
10964
10965 case DMAPDATAMAP: //byte
10966 {
10967 213 ret = ((byte)DMaps[ri->dmapsref].map + 1) * 10000; break;
10968 }
10969 case DMAPDATALEVEL: //word
10970 {
10971 ret = ((word)DMaps[ri->dmapsref].level) * 10000; break;
10972 }
10973 case DMAPDATAOFFSET: //char
10974 {
10975 6 ret = ((char)DMaps[ri->dmapsref].xoff) * 10000; break;
10976 }
10977 case DMAPDATACOMPASS: //byte
10978 {
10979 ret = ((byte)DMaps[ri->dmapsref].compass) * 10000; break;
10980 }
10981 case DMAPDATAPALETTE: //word
10982 {
10983 192 ret = ((word)DMaps[ri->dmapsref].color) * 10000; break;
10984 }
10985 case DMAPSCRIPT: //word
10986 {
10987 19 ret = (DMaps[ri->dmapsref].script) * 10000; break;
10988 }
10989 case DMAPDATAMIDI: //byte
10990 {
10991 ret = (DMaps[ri->dmapsref].midi-MIDIOFFSET_DMAP) * 10000; break;
10992 }
10993 case DMAPDATACONTINUE: //byte
10994 {
10995 ret = ((byte)DMaps[ri->dmapsref].cont) * 10000; break;
10996 }
10997 case DMAPDATATYPE: //byte
10998 {
10999 1124 ret = ((byte)DMaps[ri->dmapsref].type&dmfTYPE) * 10000; break;
11000 }
11001 case DMAPDATASIDEVIEW: //byte
11002 {
11003 733036 ret = ((DMaps[ri->dmapsref].sideview) ? 10000 : 0); break;
11004 }
11005 case DMAPDATAGRID: //byte[8] --array
11006 {
11007 43092 int32_t indx = ri->d[rINDEX] / 10000;
11008
2/4
✓ Branch 0 taken 43092 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 43092 times.
43092 if ( indx < 0 || indx > 7 )
11009 {
11010 Z_scripterrlog("Invalid index supplied to dmapdata->Grid[]: %d\n", indx);
11011 ret = -10000;
11012 break;
11013 }
11014 else
11015 {
11016 43092 ret = ((byte)DMaps[ri->dmapsref].grid[indx]) * 10000; break;
11017 }
11018 }
11019 case DMAPINITD: //byte[8] --array
11020 {
11021 45 int32_t indx = ri->d[rINDEX] / 10000;
11022
2/4
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
45 if ( indx < 0 || indx > 7 )
11023 {
11024 Z_scripterrlog("Invalid index supplied to dmapdata->InitD[]: %d\n", indx);
11025 ret = -10000;
11026 break;
11027 }
11028 else
11029 {
11030 45 ret = DMaps[ri->dmapsref].initD[indx]; break;
11031 }
11032 }
11033 case DMAPDATAMINIMAPTILE: //word - two of these, so let's do MinimapTile[2]
11034 {
11035 1402 int32_t indx = ri->d[rINDEX] / 10000;
11036
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 718 times.
✓ Branch 2 taken 684 times.
1402 switch(indx)
11037 {
11038 718 case 0: { ret = ((word)DMaps[ri->dmapsref].minimap_1_tile) * 10000; break; }
11039 684 case 1: { ret = ((word)DMaps[ri->dmapsref].minimap_2_tile) * 10000; break; }
11040 default:
11041 {
11042 Z_scripterrlog("Invalid index supplied to dmapdata->MiniMapTile[]: %d\n", indx);
11043 ret = -10000;
11044 break;
11045 }
11046 }
11047 1402 break;
11048 }
11049 case DMAPDATAMINIMAPCSET: //byte - two of these, so let's do MinimapCSet[2]
11050 {
11051 17 int32_t indx = ri->d[rINDEX] / 10000;
11052
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
17 switch(indx)
11053 {
11054 17 case 0: { ret = ((byte)DMaps[ri->dmapsref].minimap_1_cset) * 10000; break; }
11055 case 1: { ret = ((byte)DMaps[ri->dmapsref].minimap_2_cset) * 10000; break; }
11056 default:
11057 {
11058 Z_scripterrlog("Invalid index supplied to dmapdata->MiniMapCSet[]: %d\n", indx);
11059 ret = -10000;
11060 break;
11061 }
11062 }
11063 17 break;
11064 }
11065 case DMAPDATALARGEMAPTILE: //word -- two of these, so let's to LargemapTile[2]
11066 {
11067 int32_t indx = ri->d[rINDEX] / 10000;
11068 switch(indx)
11069 {
11070 case 0: { ret = ((word)DMaps[ri->dmapsref].largemap_1_tile) * 10000; break; }
11071 case 1: { ret = ((word)DMaps[ri->dmapsref].largemap_2_tile) * 10000; break; }
11072 default:
11073 {
11074 Z_scripterrlog("Invalid index supplied to dmapdata->MapTile[]: %d\n", indx);
11075 ret = -10000;
11076 break;
11077 }
11078 }
11079 break;
11080 }
11081 case DMAPDATALARGEMAPCSET: //word -- two of these, so let's to LargemaCSet[2]
11082 {
11083 int32_t indx = ri->d[rINDEX] / 10000;
11084 switch(indx)
11085 {
11086 case 0: { ret = ((byte)DMaps[ri->dmapsref].largemap_1_cset) * 10000; break; }
11087 case 1: { ret = ((byte)DMaps[ri->dmapsref].largemap_2_cset) * 10000; break; }
11088 default:
11089 {
11090 Z_scripterrlog("Invalid index supplied to dmapdata->MapCSet[]: %d\n", indx);
11091 ret = -10000;
11092 break;
11093 }
11094 }
11095 break;
11096 }
11097 case DMAPDATAMUISCTRACK: //byte
11098 {
11099 ret = ((byte)DMaps[ri->dmapsref].tmusictrack) * 10000; break;
11100 }
11101 case DMAPDATASUBSCRA: //byte, active subscreen
11102 {
11103 ret = ((byte)DMaps[ri->dmapsref].active_subscreen) * 10000; break;
11104 }
11105 case DMAPDATASUBSCRP: //byte, passive subscreen
11106 {
11107 ret = ((byte)DMaps[ri->dmapsref].passive_subscreen) * 10000; break;
11108 }
11109 case DMAPDATADISABLEDITEMS: //byte[MAXITEMS]
11110 {
11111 int32_t indx = ri->d[rINDEX] / 10000;
11112 if ( indx < 0 || indx > (MAXITEMS-1) )
11113 {
11114 Z_scripterrlog("Invalid index supplied to dmapdata->Grid[]: %d\n", indx);
11115 ret = -10000;
11116 break;
11117 }
11118 else
11119 {
11120 ret = ((byte)DMaps[ri->dmapsref].disableditems[indx]) * 10000; break;
11121 }
11122 }
11123 case DMAPDATAFLAGARR: //int32_t
11124 {
11125 6 int32_t indx = ri->d[rINDEX] / 10000;
11126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if ( ((unsigned)indx) > 31 )
11127 {
11128 Z_scripterrlog("Invalid index supplied to dmapdata->Flags[]: %d\n", indx);
11129 ret = -10000;
11130 break;
11131 }
11132 6 ret = ((DMaps[ri->dmapsref].flags&(1<<indx)) ? 10000:0);
11133 6 break;
11134 }
11135 case DMAPDATAFLAGS: //int32_t
11136 {
11137 ret = (DMaps[ri->dmapsref].flags) * 10000; break;
11138 }
11139 case DMAPDATAMIRRDMAP:
11140 {
11141 ret = (DMaps[ri->dmapsref].mirrorDMap) * 10000; break;
11142 }
11143 case DMAPDATALOOPSTART:
11144 {
11145 ret = (DMaps[ri->dmapsref].tmusic_loop_start); break;
11146 }
11147 case DMAPDATALOOPEND:
11148 {
11149 ret = (DMaps[ri->dmapsref].tmusic_loop_end); break;
11150 }
11151 case DMAPDATAXFADEIN:
11152 {
11153 ret = (DMaps[ri->dmapsref].tmusic_xfade_in * 10000); break;
11154 }
11155 case DMAPDATAXFADEOUT:
11156 {
11157 ret = (DMaps[ri->dmapsref].tmusic_xfade_out * 10000); break;
11158 }
11159 case MUSICUPDATECOND:
11160 {
11161 ret = ((byte)FFCore.music_update_cond) * 10000; break;
11162 }
11163 case MUSICUPDATEFLAGS:
11164 {
11165 int32_t indx = ri->d[rINDEX] / 10000;
11166 if (indx < 0 || indx > 2)
11167 {
11168 Z_scripterrlog("Invalid Index passed to Audio->MusicRefreshFlags[]: %d\n", indx);
11169 }
11170 ret = ((FFCore.music_update_flags >> indx) & 1) ? 10000 : 0; break;
11171 }
11172 case DMAPDATAASUBSCRIPT: //word
11173 {
11174 22016 ret = (DMaps[ri->dmapsref].active_sub_script) * 10000; break;
11175 }
11176 case DMAPDATAMAPSCRIPT: //byte
11177 {
11178 ret = (DMaps[ri->dmapsref].onmap_script) * 10000; break;
11179 }
11180 case DMAPDATAPSUBSCRIPT: //word
11181 {
11182 ret = (DMaps[ri->dmapsref].passive_sub_script) * 10000; break;
11183 }
11184 case DMAPDATASUBINITD: //byte[8] --array
11185 {
11186 int32_t indx = ri->d[rINDEX] / 10000;
11187 if ( indx < 0 || indx > 7 )
11188 {
11189 Z_scripterrlog("Invalid index supplied to dmapdata->SubInitD[]: %d\n", indx);
11190 ret = -10000;
11191 break;
11192 }
11193 else
11194 {
11195 ret = DMaps[ri->dmapsref].sub_initD[indx]; break;
11196 }
11197 }
11198
11199 case DMAPDATAMAPINITD: //byte[8] --array
11200 {
11201 int32_t indx = ri->d[rINDEX] / 10000;
11202 if ( indx < 0 || indx > 7 )
11203 {
11204 Z_scripterrlog("Invalid index supplied to dmapdata->MapInitD[]: %d\n", indx);
11205 ret = -10000;
11206 break;
11207 }
11208 else
11209 {
11210 ret = DMaps[ri->dmapsref].onmap_initD[indx]; break;
11211 }
11212 }
11213
11214 case DMAPDATACHARTED:
11215 {
11216 int32_t scr = ri->d[rINDEX] / 10000;
11217 ret = -10000;
11218 if(ri->dmapsref >= MAXDMAPS)
11219 {
11220 Z_scripterrlog("Invalid DMap reference used for dmapdata->Charted[]: %d\n", ri->dmapsref);
11221 }
11222 // else if((DMaps[get_currdmap()].type&dmfTYPE) == dmOVERW)
11223 // {
11224 // Z_scripterrlog("dmapdata->Charted[] cannot presently be used on Overworld-type dmaps\n");
11225 // }
11226 else if(((unsigned)(scr)) > 127)
11227 {
11228 Z_scripterrlog("Invalid index supplied to dmapdata->Charted[]: %d\n", scr);
11229 }
11230 else
11231 {
11232 int32_t col = (scr&15)-(DMaps[ri->dmapsref].type==dmOVERW ? 0 : DMaps[ri->dmapsref].xoff);
11233 if((DMaps[ri->dmapsref].type&dmfTYPE)!=dmOVERW ? (((unsigned)col) > 7) : (((unsigned)col) > 15))
11234 break; //Out-of-bounds; don't attempt read!
11235 int32_t di = (ri->dmapsref << 7) + (scr & 0x7F);
11236 ret = 10000 * game->bmaps[di];
11237 }
11238 break;
11239 }
11240 //case DMAPDATAGRAVITY: //unimplemented
11241 //case DMAPDATAJUMPLAYER: //unimplemented
11242
11243 ///----------------------------------------------------------------------------------------------------//
11244 //messagedata msgd-> variables
11245 case MESSAGEDATANEXT: //W
11246 {
11247 int32_t ID = ri->zmsgref;
11248
11249 if(BC::checkMessage(ID, "messagedata->Next") != SH::_NoError)
11250 {
11251 ret = -10000; break;
11252 }
11253 else
11254 {
11255 ret = ((int32_t)MsgStrings[ID].nextstring) * 10000;
11256 break;
11257 }
11258 }
11259
11260 case MESSAGEDATATILE: //W
11261 {
11262 int32_t ID = ri->zmsgref;
11263
11264 if(BC::checkMessage(ID, "messagedata->Tile") != SH::_NoError)
11265 ret = -10000;
11266 else
11267 ret = ((int32_t)MsgStrings[ID].tile) * 10000;
11268 break;
11269 }
11270
11271 case MESSAGEDATACSET: //b
11272 {
11273 int32_t ID = ri->zmsgref;
11274
11275 if(BC::checkMessage(ID, "messagedata->CSet") != SH::_NoError)
11276 ret = -10000;
11277 else
11278 ret = ((int32_t)MsgStrings[ID].cset) * 10000;
11279 break;
11280 }
11281 case MESSAGEDATATRANS: //BOOL
11282 {
11283 int32_t ID = ri->zmsgref;
11284
11285 if(BC::checkMessage(ID, "messagedata->Transparent") != SH::_NoError)
11286 ret = -10000;
11287 else
11288 ret = ((MsgStrings[ID].trans)?10000:0);
11289 break;
11290 }
11291 case MESSAGEDATAFONT: //B
11292 {
11293 int32_t ID = ri->zmsgref;
11294
11295 if(BC::checkMessage(ID, "messagedata->Font") != SH::_NoError)
11296 ret = -10000;
11297 else
11298 ret = (int32_t)MsgStrings[ID].font * 10000;
11299 break;
11300 }
11301 case MESSAGEDATAX: //SHORT
11302 {
11303 int32_t ID = ri->zmsgref;
11304
11305 if(BC::checkMessage(ID, "messagedata->X") != SH::_NoError)
11306 ret = -10000;
11307 else
11308 ret = ((int32_t)MsgStrings[ID].x) * 10000;
11309 break;
11310 }
11311 case MESSAGEDATAY: //SHORT
11312 {
11313 int32_t ID = ri->zmsgref;
11314
11315 if(BC::checkMessage(ID, "messagedata->Y") != SH::_NoError)
11316 ret = -10000;
11317 else
11318 ret = ((int32_t)MsgStrings[ID].y) * 10000;
11319 break;
11320 }
11321 case MESSAGEDATAW: //UNSIGNED SHORT
11322 {
11323 int32_t ID = ri->zmsgref;
11324
11325 if(BC::checkMessage(ID, "messagedata->Width") != SH::_NoError)
11326 ret = -10000;
11327 else
11328 ret = ((int32_t)MsgStrings[ID].w) * 10000;
11329 break;
11330 }
11331 case MESSAGEDATAH: //UNSIGNED SHORT
11332 {
11333 int32_t ID = ri->zmsgref;
11334
11335 if(BC::checkMessage(ID, "messagedata->Height") != SH::_NoError)
11336 ret = -10000;
11337 else
11338 ret = ((int32_t)MsgStrings[ID].h) * 10000;
11339 break;
11340 }
11341 case MESSAGEDATASFX: //BYTE
11342 {
11343 int32_t ID = ri->zmsgref;
11344
11345 if(BC::checkMessage(ID, "messagedata->Sound") != SH::_NoError)
11346 ret = -10000;
11347 else
11348 ret = ((int32_t)MsgStrings[ID].sfx) * 10000;
11349 break;
11350 }
11351 case MESSAGEDATALISTPOS: //WORD
11352 {
11353 int32_t ID = ri->zmsgref;
11354
11355 if(BC::checkMessage(ID, "messagedata->ListPosition") != SH::_NoError)
11356 ret = -10000;
11357 else
11358 ret = ((int32_t)MsgStrings[ID].listpos) * 10000;
11359 break;
11360 }
11361 case MESSAGEDATAVSPACE: //BYTE
11362 {
11363 int32_t ID = ri->zmsgref;
11364
11365 if(BC::checkMessage(ID, "messagedata->VSpace") != SH::_NoError)
11366 ret = -10000;
11367 else
11368 ret = ((int32_t)MsgStrings[ID].vspace) * 10000;
11369 break;
11370 }
11371 case MESSAGEDATAHSPACE: //BYTE
11372 {
11373 int32_t ID = ri->zmsgref;
11374
11375 if(BC::checkMessage(ID, "messagedata->HSpace") != SH::_NoError)
11376 ret = -10000;
11377 else
11378 ret = ((int32_t)MsgStrings[ID].hspace) * 10000;
11379 break;
11380 }
11381 case MESSAGEDATAFLAGS: //BYTE
11382 {
11383 int32_t ID = ri->zmsgref;
11384
11385 if(BC::checkMessage(ID, "messagedata->Flags") != SH::_NoError)
11386 ret = -10000;
11387 else
11388 ret = ((int32_t)MsgStrings[ID].stringflags) * 10000;
11389 break;
11390 }
11391 case MESSAGEDATAMARGINS: //BYTE, 4
11392 {
11393 int32_t indx = ri->d[rINDEX] / 10000;
11394 if ( indx < 0 || indx > 3 )
11395 {
11396 Z_scripterrlog("Invalid index supplied to messagedata->Margins[]: %d\n", indx);
11397 ret = -10000;
11398 break;
11399 }
11400 int32_t ID = ri->zmsgref;
11401
11402 if(BC::checkMessage(ID, "messagedata->Margins[]") != SH::_NoError)
11403 ret = -10000;
11404 else
11405 ret = ((int32_t)MsgStrings[ID].margins[indx]) * 10000;
11406 break;
11407 }
11408 case MESSAGEDATAPORTTILE: //INT
11409 {
11410 int32_t ID = ri->zmsgref;
11411
11412 if(BC::checkMessage(ID, "messagedata->PortraitTile") != SH::_NoError)
11413 ret = -10000;
11414 else
11415 ret = ((int32_t)MsgStrings[ID].portrait_tile) * 10000;
11416 break;
11417 }
11418 case MESSAGEDATAPORTCSET: //BYTE
11419 {
11420 int32_t ID = ri->zmsgref;
11421
11422 if(BC::checkMessage(ID, "messagedata->PortraitCSet") != SH::_NoError)
11423 ret = -10000;
11424 else
11425 ret = ((int32_t)MsgStrings[ID].portrait_cset) * 10000;
11426 break;
11427 }
11428 case MESSAGEDATAPORTX: //BYTE
11429 {
11430 int32_t ID = ri->zmsgref;
11431
11432 if(BC::checkMessage(ID, "messagedata->PortraitX") != SH::_NoError)
11433 ret = -10000;
11434 else
11435 ret = ((int32_t)MsgStrings[ID].portrait_x) * 10000;
11436 break;
11437 }
11438 case MESSAGEDATAPORTY: //BYTE
11439 {
11440 int32_t ID = ri->zmsgref;
11441
11442 if(BC::checkMessage(ID, "messagedata->PortraitY") != SH::_NoError)
11443 ret = -10000;
11444 else
11445 ret = ((int32_t)MsgStrings[ID].portrait_y) * 10000;
11446 break;
11447 }
11448 case MESSAGEDATAPORTWID: //BYTE
11449 {
11450 int32_t ID = ri->zmsgref;
11451
11452 if(BC::checkMessage(ID, "messagedata->PortraitTileWidth") != SH::_NoError)
11453 ret = -10000;
11454 else
11455 ret = ((int32_t)MsgStrings[ID].portrait_tw) * 10000;
11456 break;
11457 }
11458 case MESSAGEDATAPORTHEI: //BYTE
11459 {
11460 int32_t ID = ri->zmsgref;
11461
11462 if(BC::checkMessage(ID, "messagedata->PortraitTileHeight") != SH::_NoError)
11463 ret = -10000;
11464 else
11465 ret = ((int32_t)MsgStrings[ID].portrait_th) * 10000;
11466 break;
11467 }
11468 case MESSAGEDATATEXTLEN: //BYTE
11469 {
11470 int32_t ID = ri->zmsgref;
11471
11472 if(BC::checkMessage(ID, "messagedata->PortraitTileHeight") != SH::_NoError)
11473 ret = -10000;
11474 else
11475 ret = int32_t(MsgStrings[ID].s.size()) * 10000;
11476 break;
11477 }
11478 case MESSAGEDATATEXTWID:
11479 {
11480 ret = do_msgwidth(ri->zmsgref, "messagedata->TextWidth")*10000;
11481 break;
11482 }
11483 case MESSAGEDATATEXTHEI:
11484 {
11485 ret = do_msgheight(ri->zmsgref, "messagedata->TextHeight")*10000;
11486 break;
11487 }
11488 case MESSAGEDATAFLAGSARR: //BOOL, 7
11489 {
11490 int32_t indx = ri->d[rINDEX] / 10000;
11491 int32_t ID = ri->zmsgref;
11492
11493 if(BC::checkMessage(ID, "messagedata->Flags[]") != SH::_NoError)
11494 ret = -10000;
11495 else
11496 {
11497 switch(indx)
11498 {
11499 case 0:
11500 ret = (MsgStrings[ID].stringflags & STRINGFLAG_WRAP)!=0 ? 10000 : 0;
11501 break;
11502 case 1:
11503 ret = (MsgStrings[ID].stringflags & STRINGFLAG_CONT)!=0 ? 10000 : 0;
11504 break;
11505 case 2: //Not implemented
11506 ret = 0;//ret = (MsgStrings[ID].stringflags & STRINGFLAG_CENTER)!=0 ? 10000 : 0;
11507 break;
11508 case 3: //Not implemented
11509 ret = 0;//ret = (MsgStrings[ID].stringflags & STRINGFLAG_RIGHT)!=0 ? 10000 : 0;
11510 break;
11511 case 4:
11512 ret = (MsgStrings[ID].stringflags & STRINGFLAG_FULLTILE)!=0 ? 10000 : 0;
11513 break;
11514 case 5:
11515 ret = (MsgStrings[ID].stringflags & STRINGFLAG_TRANS_BG)!=0 ? 10000 : 0;
11516 break;
11517 case 6:
11518 ret = (MsgStrings[ID].stringflags & STRINGFLAG_TRANS_FG)!=0 ? 10000 : 0;
11519 break;
11520 default:
11521 Z_scripterrlog("Invalid index supplied to messagedata->Flags[]: %d\n", indx);
11522 ret = -10000;
11523 }
11524 }
11525 break;
11526 }
11527
11528 ///----------------------------------------------------------------------------------------------------//
11529 //combodata cd-> Getter variables
11530 #define GET_COMBO_VAR_INT(member, str) \
11531 { \
11532 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11533 { \
11534 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11535 ret = -10000; \
11536 } \
11537 else \
11538 { \
11539 ret = (combobuf[ri->combosref].member *10000); \
11540 } \
11541 } \
11542
11543 #define GET_COMBO_VAR_BYTE(member, str) \
11544 { \
11545 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11546 { \
11547 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11548 ret = -10000; \
11549 } \
11550 else \
11551 { \
11552 ret = (combobuf[ri->combosref].member *10000); \
11553 } \
11554 } \
11555
11556 #define GET_COMBO_VAR_DWORD(member, str) \
11557 { \
11558 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11559 { \
11560 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11561 ret = -10000; \
11562 } \
11563 else \
11564 { \
11565 ret = (combobuf[ri->combosref].member *10000); \
11566 } \
11567 } \
11568
11569 #define GET_COMBO_VAR_INDEX(member, str, indexbound) \
11570 { \
11571 int32_t indx = ri->d[rINDEX] / 10000; \
11572 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11573 { \
11574 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11575 ret = -10000; \
11576 } \
11577 else if ( indx < 0 || indx >= indexbound ) \
11578 { \
11579 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
11580 ret = -10000; \
11581 } \
11582 else \
11583 { \
11584 ret = (combobuf[ri->combosref].member[indx] * 10000); \
11585 } \
11586 }
11587
11588 #define GET_COMBO_BYTE_INDEX(member, str, indexbound) \
11589 { \
11590 int32_t indx = ri->d[rINDEX] / 10000; \
11591 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11592 { \
11593 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11594 ret = -10000; \
11595 } \
11596 else if ( indx < 0 || indx >= indexbound ) \
11597 { \
11598 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
11599 ret = -10000; \
11600 } \
11601 else \
11602 { \
11603 ret = (combobuf[ri->combosref].member[indx] * 100000); \
11604 } \
11605 }
11606
11607 #define GET_COMBO_FLAG(member, str, indexbound) \
11608 { \
11609 int32_t flag = (value/10000); \
11610 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11611 { \
11612 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11613 } \
11614 else \
11615 { \
11616 ret = (combobuf[ri->combosref].member&flag) ? 10000 : 0); \
11617 } \
11618 } \
11619
11620 //comboclass macros
11621
11622 #define GET_COMBOCLASS_VAR_INT(member, str) \
11623 { \
11624 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11625 { \
11626 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11627 ret = -10000; \
11628 } \
11629 else \
11630 { \
11631 ret = (combo_class_buf[combobuf[ri->combosref].type].member *10000); \
11632 } \
11633 } \
11634
11635 #define GET_COMBOCLASS_VAR_BYTE(member, str) \
11636 { \
11637 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11638 { \
11639 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11640 ret = -10000; \
11641 } \
11642 else \
11643 { \
11644 ret = (combo_class_buf[combobuf[ri->combosref].type].member *10000); \
11645 } \
11646 } \
11647
11648 #define GET_COMBOCLASS_VAR_DWORD(member, str) \
11649 { \
11650 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11651 { \
11652 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11653 ret = -10000; \
11654 } \
11655 else \
11656 { \
11657 ret = (combo_class_buf[combobuf[ri->combosref].type].member *10000); \
11658 } \
11659 } \
11660
11661 #define GET_COMBOCLASS_VAR_INDEX(member, str, indexbound) \
11662 { \
11663 int32_t indx = ri->d[rINDEX] / 10000; \
11664 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11665 { \
11666 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11667 ret = -10000; \
11668 } \
11669 else if ( indx < 0 || indx > indexbound ) \
11670 { \
11671 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
11672 ret = -10000; \
11673 } \
11674 else \
11675 { \
11676 ret = (combo_class_buf[combobuf[ri->combosref].type].member[indx] * 10000); \
11677 } \
11678 }
11679
11680 #define GET_COMBOCLASS_BYTE_INDEX(member, str, indexbound) \
11681 { \
11682 int32_t indx = ri->d[rINDEX] / 10000; \
11683 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11684 { \
11685 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11686 ret = -10000; \
11687 } \
11688 else if ( indx < 0 || indx > indexbound ) \
11689 { \
11690 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
11691 ret = -10000; \
11692 } \
11693 else \
11694 { \
11695 ret = (combo_class_buf[combobuf[ri->combosref].type].member[indx] * 100000); \
11696 } \
11697 }
11698
11699 #define GET_COMBOCLASS_FLAG(member, str, indexbound) \
11700 { \
11701 int32_t flag = (value/10000); \
11702 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11703 { \
11704 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11705 } \
11706 else \
11707 { \
11708 ret = (combo_class_buf[combobuf[ri->combosref].type].member&flag) ? 10000 : 0); \
11709 } \
11710 } \
11711
11712 case COMBOXR:
11713 {
11714 //ri->combosref = id; //'this' pointer
11715 //ri->comboposref = i; //used for X(), Y(), Layer(), and so forth.
11716
1/2
✓ Branch 0 taken 11261 times.
✗ Branch 1 not taken.
11261 if ( curScriptType == ScriptType::Combo )
11717 {
11718 11261 int pos = combopos_ref_to_pos(ri->comboposref);
11719 11261 ret = (( COMBOX(pos) ) * 10000); //comboscriptstack[i]
11720 //this may be wrong...may need a special new var for this, storing the exact combopos
11721 //i is the current script number
11722 11261 }
11723 else
11724 {
11725 Z_scripterrlog("combodata->X() can only be called by combodata scripts, but you tried to use it from script type %s, script token %s\n", ScriptTypeToString(curScriptType), comboscriptmap[ri->combosref].scriptname.c_str() );
11726 ret = -10000;
11727 }
11728 11261 break;
11729 }
11730
11731 case COMBOYR:
11732 {
11733
1/2
✓ Branch 0 taken 11261 times.
✗ Branch 1 not taken.
11261 if ( curScriptType == ScriptType::Combo )
11734 {
11735 11261 int pos = combopos_ref_to_pos(ri->comboposref);
11736 11261 ret = (( COMBOY(pos) ) * 10000); //comboscriptstack[i]
11737 11261 }
11738 else
11739 {
11740 Z_scripterrlog("combodata->Y() can only be called by combodata scripts, but you tried to use it from script type %s, script token %s\n", ScriptTypeToString(curScriptType), comboscriptmap[ri->combosref].scriptname.c_str() );
11741 ret = -10000;
11742 }
11743 11261 break;
11744 }
11745 case COMBOPOSR:
11746 {
11747
1/2
✓ Branch 0 taken 33759 times.
✗ Branch 1 not taken.
33759 if ( curScriptType == ScriptType::Combo )
11748 {
11749 33759 int pos = combopos_ref_to_pos(ri->comboposref);
11750 33759 ret = pos * 10000; //comboscriptstack[i]
11751 33759 }
11752 else
11753 {
11754 Z_scripterrlog("combodata->Pos() can only be called by combodata scripts, but you tried to use it from script type %s, script token %s\n", ScriptTypeToString(curScriptType), comboscriptmap[ri->combosref].scriptname.c_str() );
11755 ret = -10000;
11756 }
11757 33759 break;
11758 }
11759 case COMBOLAYERR:
11760 {
11761
1/2
✓ Branch 0 taken 11044 times.
✗ Branch 1 not taken.
11044 if ( curScriptType == ScriptType::Combo )
11762 {
11763 11044 ret = (( ((ri->comboposref)/176) ) * 10000); //comboscriptstack[i]
11764 11044 }
11765 else
11766 {
11767 Z_scripterrlog("combodata->Pos() can only be called by combodata scripts, but you tried to use it from script type %s, script token %s\n", ScriptTypeToString(curScriptType), comboscriptmap[ri->combosref].scriptname.c_str() );
11768 ret = -10000;
11769 }
11770 11044 break;
11771 }
11772
11773 //NEWCOMBO STRUCT
11774
2/4
✓ Branch 0 taken 4546 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4546 times.
4546 case COMBODTILE: GET_COMBO_VAR_DWORD(tile, "Tile"); break; //word
11775 case COMBODOTILE: GET_COMBO_VAR_DWORD(o_tile, "OriginalTile"); break; //word
11776 case COMBODFRAME: GET_COMBO_VAR_BYTE(cur_frame, "Frame"); break; //char
11777 case COMBODACLK: GET_COMBO_VAR_BYTE(aclk, "AClk"); break; //char
11778 case COMBODASPEED: GET_COMBO_VAR_BYTE(speed, "ASpeed"); break; //char
11779
2/4
✓ Branch 0 taken 4546 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4546 times.
4546 case COMBODFLIP: GET_COMBO_VAR_BYTE(flip, "Flip"); break; //char
11780 case COMBODWALK:
11781 {
11782 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11783 {
11784 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Walk");
11785 ret = -10000;
11786 }
11787 else
11788 {
11789 ret = ((combobuf[ri->combosref].walk&0x0F) *10000);
11790 }
11791 break;
11792 }
11793 case COMBODEFFECT:
11794 {
11795 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11796 {
11797 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Effect");
11798 ret = -10000;
11799 }
11800 else
11801 {
11802 ret = (((combobuf[ri->combosref].walk&0xF0)>>4) *10000);
11803 }
11804 break;
11805 }
11806
2/4
✓ Branch 0 taken 4890 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4890 times.
4890 case COMBODTYPE: GET_COMBO_VAR_BYTE(type, "Type"); break; //char
11807 case COMBODCSET:
11808 {
11809 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11810 {
11811 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "CSet2");
11812 ret = -10000;
11813 }
11814 else
11815 {
11816 bool neg = combobuf[ri->combosref].csets&0x8;
11817 ret = ((combobuf[ri->combosref].csets&0x7) * (neg ? -10000 : 10000));
11818 }
11819 break;
11820 }
11821 case COMBODCSET2FLAGS:
11822 {
11823 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11824 {
11825 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "CSet2Flags");
11826 }
11827 else
11828 {
11829 ret = ((combobuf[ri->combosref].csets & 0xF0) >> 4) * 10000;
11830 }
11831 break;
11832 }
11833 case COMBODFOO: break; //W
11834
2/4
✓ Branch 0 taken 22172 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 22172 times.
22172 case COMBODATASCRIPT: GET_COMBO_VAR_DWORD(script, "Script"); break; //W
11835 case COMBODFRAMES: GET_COMBO_VAR_BYTE(frames, "Frames"); break; //C
11836 case COMBODNEXTD: GET_COMBO_VAR_DWORD(speed, "NextData"); break; //W
11837 case COMBODNEXTC: GET_COMBO_VAR_BYTE(nextcombo, "NextCSet"); break; //C
11838 case COMBODFLAG: GET_COMBO_VAR_BYTE(nextcset, "Flag"); break; //C
11839 case COMBODSKIPANIM: GET_COMBO_VAR_BYTE(skipanim, "SkipAnim"); break; //C
11840 case COMBODNEXTTIMER: GET_COMBO_VAR_DWORD(nexttimer, "NextTimer"); break; //W
11841 case COMBODAKIMANIMY: GET_COMBO_VAR_BYTE(skipanimy, "SkipAnimY"); break; //C
11842 case COMBODANIMFLAGS: GET_COMBO_VAR_BYTE(animflags, "AnimFlags"); break; //C
11843 case COMBODEXPANSION: GET_COMBO_BYTE_INDEX(expansion, "Expansion[]", 6); break; //C , 6 INDICES
11844 case COMBODATTRIBUTES:
11845 {
11846 66 int32_t indx = ri->d[rINDEX] / 10000;
11847
2/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66 times.
66 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11848 {
11849 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Attributes[]");
11850 ret = -10000;
11851 }
11852
2/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66 times.
66 else if ( indx < 0 || indx > 4 )
11853 {
11854 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "Attributes[]");
11855 ret = -10000;
11856 }
11857 else
11858 {
11859 66 ret = (combobuf[ri->combosref].attributes[indx]);
11860 }
11861 }
11862 66 break;
11863 //case COMBODATAINITD: GET_COMBO_VAR_INDEX(initd, "InitD[]", 2); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
11864 case COMBODATAINITD:
11865 {
11866 1636 int32_t indx = ri->d[rINDEX] / 10000;
11867
2/4
✓ Branch 0 taken 1636 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1636 times.
1636 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11868 {
11869 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "InitD[]");
11870 ret = -10000;
11871 }
11872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1636 times.
1636 else if ( ((unsigned)indx) > 2 )
11873 {
11874 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "InitD[]");
11875 ret = -10000;
11876 }
11877 else
11878 {
11879 1636 ret = (combobuf[ri->combosref].initd[indx] * (get_qr(qr_COMBODATA_INITD_MULT_TENK) ? 10000 : 1));
11880 }
11881 1636 break;
11882 }
11883
4/8
✓ Branch 0 taken 568 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 568 times.
✓ Branch 4 taken 568 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 568 times.
1136 case COMBODATTRIBYTES: GET_COMBO_VAR_INDEX(attribytes, "Attribytes[]", 8); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
11884
4/8
✓ Branch 0 taken 136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
✓ Branch 4 taken 136 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 136 times.
272 case COMBODATTRISHORTS: GET_COMBO_VAR_INDEX(attrishorts, "Attrishorts[]", 8); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
11885 case COMBODUSRFLAGARR:
11886 {
11887 int32_t indx = ri->d[rINDEX] / 10000;
11888 if (ri->combosref < 0 || ri->combosref >(MAXCOMBOS - 1))
11889 {
11890 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", "Flags[]", (ri->combosref * 10000));
11891 ret = 0;
11892 }
11893 else if (((unsigned)indx) > 15)
11894 {
11895 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", "Flags[]", indx);
11896 ret = 0;
11897 }
11898 else
11899 {
11900 ret = (combobuf[ri->combosref].usrflags & 1 << indx) ? 10000L : 0L;
11901 }
11902 break;
11903 }
11904 case COMBODGENFLAGARR:
11905 {
11906 int32_t indx = ri->d[rINDEX] / 10000;
11907 if (ri->combosref < 0 || ri->combosref >(MAXCOMBOS - 1))
11908 {
11909 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", "GenFlags[]", (ri->combosref * 10000));
11910 ret = 0;
11911 }
11912 else if (((unsigned)indx) > 1)
11913 {
11914 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", "GenFlags[]", indx);
11915 ret = 0;
11916 }
11917 else
11918 {
11919 ret = (combobuf[ri->combosref].genflags & (1 << indx)) ? 10000L : 0L;
11920 }
11921 break;
11922 }
11923 case COMBODUSRFLAGS: GET_COMBO_VAR_INT(usrflags, "UserFlags"); break; //LONG
11924 case COMBODTRIGGERFLAGS: GET_COMBO_VAR_INDEX(triggerflags, "TriggerFlags[]", 6); break; //LONG 3 INDICES AS FLAGSETS
11925 case COMBODTRIGGERFLAGS2:
11926 {
11927 int32_t indx = ri->d[rINDEX] / 10000;
11928 ret = -10000;
11929 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11930 {
11931 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TrigFlags[]");
11932 }
11933 else if ( unsigned(indx) >= 32*6 )
11934 {
11935 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "TrigFlags[]");
11936 }
11937 else
11938 {
11939 ret = (combobuf[ri->combosref].triggerflags[indx/32] & (1<<indx%32)) ? 10000L : 0L;
11940 }
11941 break;
11942 }
11943 case COMBODTRIGGERBUTTON:
11944 {
11945 int32_t indx = ri->d[rINDEX] / 10000;
11946 ret = -10000;
11947 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11948 {
11949 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerButton[]");
11950 }
11951 else if ( unsigned(indx) >= 8 )
11952 {
11953 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "TriggerButton[]");
11954 }
11955 else
11956 {
11957 ret = (combobuf[ri->combosref].triggerbtn & (1<<indx)) ? 10000L : 0L;
11958 }
11959 break;
11960 }
11961 case COMBODTRIGGERITEM:
11962 {
11963 ret = -10000;
11964 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11965 {
11966 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerItem");
11967 }
11968 else ret = (combobuf[ri->combosref].triggeritem) * 10000;
11969 break;
11970 }
11971 case COMBODTRIGGERTIMER:
11972 {
11973 ret = -10000;
11974 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11975 {
11976 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerTimer");
11977 }
11978 else ret = (combobuf[ri->combosref].trigtimer) * 10000;
11979 break;
11980 }
11981 case COMBODTRIGGERSFX:
11982 {
11983 ret = -10000;
11984 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11985 {
11986 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerSFX");
11987 }
11988 else ret = (combobuf[ri->combosref].trigsfx) * 10000;
11989 break;
11990 }
11991 case COMBODTRIGGERCHANGECMB:
11992 {
11993 ret = -10000;
11994 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11995 {
11996 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerChange");
11997 }
11998 else ret = (combobuf[ri->combosref].trigchange) * 10000;
11999 break;
12000 }
12001 case COMBODTRIGGERPROX:
12002 {
12003 ret = -10000;
12004 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12005 {
12006 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerProximity");
12007 }
12008 else ret = (combobuf[ri->combosref].trigprox) * 10000;
12009 break;
12010 }
12011 case COMBODTRIGGERLIGHTBEAM:
12012 {
12013 ret = -10000;
12014 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12015 {
12016 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerLightBeam");
12017 }
12018 else ret = (combobuf[ri->combosref].triglbeam) * 10000;
12019 break;
12020 }
12021 case COMBODTRIGGERCTR:
12022 {
12023 ret = -10000;
12024 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12025 {
12026 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerCounter");
12027 }
12028 else ret = (combobuf[ri->combosref].trigctr) * 10000;
12029 break;
12030 }
12031 case COMBODTRIGGERCTRAMNT:
12032 {
12033 ret = -10000;
12034 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12035 {
12036 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerCtrAmount");
12037 }
12038 else ret = (combobuf[ri->combosref].trigctramnt) * 10000;
12039 break;
12040 }
12041 case COMBODTRIGGERCOOLDOWN:
12042 {
12043 ret = -10000;
12044 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12045 {
12046 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerCooldown: %d\n", (ri->combosref*10000));
12047 }
12048 else ret = (combobuf[ri->combosref].trigcooldown) * 10000;
12049 break;
12050 }
12051 case COMBODTRIGGERCOPYCAT:
12052 {
12053 ret = -10000;
12054 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12055 {
12056 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerCopycat: %d\n", (ri->combosref*10000));
12057 }
12058 else ret = (combobuf[ri->combosref].trigcopycat) * 10000;
12059 break;
12060 }
12061 case COMBODTRIGITEMPICKUP:
12062 {
12063 ret = -10000;
12064 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12065 {
12066 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerSpawnItemPickup: %d\n", (ri->combosref*10000));
12067 }
12068 else ret = (combobuf[ri->combosref].spawnip) * 10000;
12069 break;
12070 }
12071 case COMBODTRIGEXSTATE:
12072 {
12073 ret = -10000;
12074 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12075 {
12076 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigExState: %d\n", (ri->combosref*10000));
12077 }
12078 else ret = (combobuf[ri->combosref].exstate) * 10000;
12079 break;
12080 }
12081 case COMBODTRIGSPAWNENEMY:
12082 {
12083 ret = -10000;
12084 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12085 {
12086 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigSpawnEnemy: %d\n", (ri->combosref*10000));
12087 }
12088 else ret = (combobuf[ri->combosref].spawnenemy) * 10000;
12089 break;
12090 }
12091 case COMBODTRIGSPAWNITEM:
12092 {
12093 ret = -10000;
12094 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12095 {
12096 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigSpawnItem: %d\n", (ri->combosref*10000));
12097 }
12098 else ret = (combobuf[ri->combosref].spawnitem) * 10000;
12099 break;
12100 }
12101 case COMBODTRIGCSETCHANGE:
12102 {
12103 ret = -10000;
12104 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12105 {
12106 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigCSetChange: %d\n", (ri->combosref*10000));
12107 }
12108 else ret = (combobuf[ri->combosref].trigcschange) * 10000;
12109 break;
12110 }
12111 case COMBODLIFTGFXCOMBO:
12112 {
12113 ret = -10000;
12114 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12115 {
12116 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXCombo: %d\n", (ri->combosref*10000));
12117 }
12118 else ret = (combobuf[ri->combosref].liftcmb) * 10000;
12119 break;
12120 }
12121 case COMBODLIFTGFXCCSET:
12122 {
12123 ret = -10000;
12124 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12125 {
12126 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXCSet: %d\n", (ri->combosref*10000));
12127 }
12128 else ret = (combobuf[ri->combosref].liftcs) * 10000;
12129 break;
12130 }
12131 case COMBODLIFTUNDERCMB:
12132 {
12133 ret = -10000;
12134 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12135 {
12136 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftUnderCombo: %d\n", (ri->combosref*10000));
12137 }
12138 else ret = (combobuf[ri->combosref].liftundercmb) * 10000;
12139 break;
12140 }
12141 case COMBODLIFTUNDERCS:
12142 {
12143 ret = -10000;
12144 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12145 {
12146 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftUnderCSet: %d\n", (ri->combosref*10000));
12147 }
12148 else ret = (combobuf[ri->combosref].liftundercs) * 10000;
12149 break;
12150 }
12151 case COMBODLIFTDAMAGE:
12152 {
12153 ret = -10000;
12154 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12155 {
12156 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftDamage: %d\n", (ri->combosref*10000));
12157 }
12158 else ret = (combobuf[ri->combosref].liftdmg) * 10000;
12159 break;
12160 }
12161 case COMBODLIFTLEVEL:
12162 {
12163 ret = -10000;
12164 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12165 {
12166 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftLevel: %d\n", (ri->combosref*10000));
12167 }
12168 else ret = (combobuf[ri->combosref].liftlvl) * 10000;
12169 break;
12170 }
12171 case COMBODLIFTITEM:
12172 {
12173 ret = -10000;
12174 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12175 {
12176 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftItem: %d\n", (ri->combosref*10000));
12177 }
12178 else ret = (combobuf[ri->combosref].liftitm) * 10000;
12179 break;
12180 }
12181 case COMBODLIFTFLAGS:
12182 {
12183 ret = -10000;
12184 int32_t indx = ri->d[rINDEX] / 10000;
12185 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12186 {
12187 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftFlags[]: %d\n", (ri->combosref*10000));
12188 break;
12189 }
12190 if ( unsigned(indx) > 7 )
12191 {
12192 Z_scripterrlog("Invalid index supplied to combodata->LiftFlags[]: %d\n", indx);
12193 break;
12194 }
12195 ret = (combobuf[ri->combosref].liftflags & (1<<indx)) ? 10000 : 0;
12196 break;
12197 }
12198 case COMBODLIFTGFXTYPE:
12199 {
12200 ret = -10000;
12201 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12202 {
12203 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXType: %d\n", (ri->combosref*10000));
12204 }
12205 else ret = (combobuf[ri->combosref].liftgfx) * 10000;
12206 break;
12207 }
12208 case COMBODLIFTGFXSPRITE:
12209 {
12210 ret = -10000;
12211 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12212 {
12213 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXSprite: %d\n", (ri->combosref*10000));
12214 }
12215 else ret = (combobuf[ri->combosref].liftsprite) * 10000;
12216 break;
12217 }
12218 case COMBODLIFTSFX:
12219 {
12220 ret = -10000;
12221 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12222 {
12223 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftSFX: %d\n", (ri->combosref*10000));
12224 }
12225 else ret = (combobuf[ri->combosref].liftsfx) * 10000;
12226 break;
12227 }
12228 case COMBODLIFTBREAKSPRITE:
12229 {
12230 ret = -10000;
12231 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12232 {
12233 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftBreakSprite: %d\n", (ri->combosref*10000));
12234 }
12235 else ret = (combobuf[ri->combosref].liftbreaksprite) * 10000;
12236 break;
12237 }
12238 case COMBODLIFTBREAKSFX:
12239 {
12240 ret = -10000;
12241 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12242 {
12243 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftBreakSFX: %d\n", (ri->combosref*10000));
12244 }
12245 else ret = (combobuf[ri->combosref].liftbreaksfx) * 10000;
12246 break;
12247 }
12248 case COMBODLIFTHEIGHT:
12249 {
12250 ret = -10000;
12251 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12252 {
12253 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftHeight: %d\n", (ri->combosref*10000));
12254 }
12255 else ret = (combobuf[ri->combosref].lifthei) * 10000;
12256 break;
12257 }
12258 case COMBODLIFTTIME:
12259 {
12260 ret = -10000;
12261 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12262 {
12263 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftTime: %d\n", (ri->combosref*10000));
12264 }
12265 else ret = (combobuf[ri->combosref].lifttime) * 10000;
12266 break;
12267 }
12268 case COMBODLIFTWEAPONITEM:
12269 {
12270 ret = -10000;
12271 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12272 {
12273 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftWeaponItem: %d\n", (ri->combosref*10000));
12274 }
12275 else ret = (combobuf[ri->combosref].lift_parent_item) * 10000;
12276 break;
12277 }
12278 case COMBODTRIGGERLSTATE:
12279 {
12280 ret = -10000;
12281 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12282 {
12283 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigLevelState: %d\n", (ri->combosref*10000));
12284 }
12285 else ret = (combobuf[ri->combosref].trig_lstate) * 10000;
12286 break;
12287 }
12288 case COMBODTRIGGERGSTATE:
12289 {
12290 ret = -10000;
12291 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12292 {
12293 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGlobalState: %d\n", (ri->combosref*10000));
12294 }
12295 else ret = (combobuf[ri->combosref].trig_gstate) * 10000;
12296 break;
12297 }
12298 case COMBODTRIGGERGROUP:
12299 {
12300 ret = -10000;
12301 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12302 {
12303 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGroup: %d\n", (ri->combosref*10000));
12304 }
12305 else ret = (combobuf[ri->combosref].trig_group) * 10000;
12306 break;
12307 }
12308 case COMBODTRIGGERGROUPVAL:
12309 {
12310 ret = -10000;
12311 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12312 {
12313 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGroupVal: %d\n", (ri->combosref*10000));
12314 }
12315 else ret = (combobuf[ri->combosref].trig_group_val) * 10000;
12316 break;
12317 }
12318 case COMBODTRIGGERGTIMER:
12319 {
12320 ret = -10000;
12321 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12322 {
12323 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGStateTimer: %d\n", (ri->combosref*10000));
12324 }
12325 else ret = (combobuf[ri->combosref].trig_statetime) * 10000;
12326 break;
12327 }
12328 case COMBODTRIGGERGENSCRIPT:
12329 {
12330 ret = -10000;
12331 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12332 {
12333 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGenScript: %d\n", (ri->combosref*10000));
12334 }
12335 else ret = (combobuf[ri->combosref].trig_genscr) * 10000;
12336 break;
12337 }
12338
12339 case COMBODTRIGGERLEVEL: GET_COMBO_VAR_INT(triggerlevel, "TriggerLevel"); break; //LONG
12340 10673 case COMBODATAID: ret = (ri->combosref*10000); break;
12341 //COMBOCLASS STRUCT
12342 //case COMBODNAME: //CHAR[64], STRING
12343 case COMBODBLOCKNPC: GET_COMBOCLASS_VAR_BYTE(block_enemies, "BlockNPC"); break; //C
12344 case COMBODBLOCKHOLE: GET_COMBOCLASS_VAR_BYTE(block_hole, "BlockHole"); break; //C
12345 case COMBODBLOCKTRIG: GET_COMBOCLASS_VAR_BYTE(block_trigger, "BlockTrigger"); break; //C
12346 case COMBODBLOCKWEAPON: GET_COMBOCLASS_BYTE_INDEX(block_weapon, "BlockWeapon[]", 32); break; //C, 32 INDICES
12347 case COMBODCONVXSPEED: GET_COMBOCLASS_VAR_DWORD(conveyor_x_speed, "ConveyorSpeedX"); break; //SHORT
12348 case COMBODCONVYSPEED: GET_COMBOCLASS_VAR_DWORD(conveyor_y_speed, "ConveyorSpeedY"); break; //SHORT
12349 case COMBODSPAWNNPC: GET_COMBOCLASS_VAR_DWORD(create_enemy, "SpawnNPC"); break; //W
12350 case COMBODSPAWNNPCWHEN: GET_COMBOCLASS_VAR_BYTE(create_enemy_when, "SpawnNPCWhen"); break; //C
12351 case COMBODSPAWNNPCCHANGE: GET_COMBOCLASS_VAR_INT(create_enemy_change, "SpawnNPCChange"); break; //LONG
12352 case COMBODDIRCHANGETYPE: GET_COMBOCLASS_VAR_BYTE(directional_change_type, "DirChange"); break; //C
12353 case COMBODDISTANCECHANGETILES: GET_COMBOCLASS_VAR_INT(distance_change_tiles, "DistanceChangeTiles"); break; //LONG
12354 case COMBODDIVEITEM: GET_COMBOCLASS_VAR_DWORD(dive_item, "DiveItem"); break; //SHORT
12355 case COMBODDOCK: GET_COMBOCLASS_VAR_BYTE(dock, "Dock"); break; //C
12356 case COMBODFAIRY: GET_COMBOCLASS_VAR_BYTE(fairy, "Fairy"); break; //C
12357 case COMBODFFATTRCHANGE: GET_COMBOCLASS_VAR_BYTE(ff_combo_attr_change, "FFCAttributeChange"); break; //C
12358 case COMBODFOORDECOTILE: GET_COMBOCLASS_VAR_INT(foot_decorations_tile, "DecorationTile"); break; //LONG
12359 case COMBODFOORDECOTYPE: GET_COMBOCLASS_VAR_BYTE(foot_decorations_type, "DecorationType"); break; //C
12360 case COMBODHOOKSHOTPOINT: GET_COMBOCLASS_VAR_BYTE(hookshot_grab_point, "Hookshot"); break; //C
12361 case COMBODLADDERPASS: GET_COMBOCLASS_VAR_BYTE(ladder_pass, "Ladder"); break; //C
12362 case COMBODLOCKBLOCK: GET_COMBOCLASS_VAR_BYTE(lock_block_type, "LockBlock"); break; //C
12363 case COMBODLOCKBLOCKCHANGE: GET_COMBOCLASS_VAR_INT(lock_block_change, "LockBlockChange"); break; //LONG
12364 case COMBODMAGICMIRROR: GET_COMBOCLASS_VAR_BYTE(magic_mirror_type, "Mirror"); break; //C
12365 case COMBODMODHPAMOUNT: GET_COMBOCLASS_VAR_DWORD(modify_hp_amount, "DamageAmount"); break; //SHORT
12366 case COMBODMODHPDELAY: GET_COMBOCLASS_VAR_BYTE(modify_hp_delay, "DamageDelay"); break; //C
12367 case COMBODMODHPTYPE: GET_COMBOCLASS_VAR_BYTE(modify_hp_type, "DamageType"); break; //C
12368 case COMBODNMODMPAMOUNT: GET_COMBOCLASS_VAR_DWORD(modify_mp_amount, "MagicAmount"); break; //SHORT
12369 case COMBODMODMPDELAY: GET_COMBOCLASS_VAR_BYTE(modify_mp_delay, "MagicDelay"); break; //C
12370 case COMBODMODMPTYPE: GET_COMBOCLASS_VAR_BYTE(modify_mp_type, "MagicType"); break; //C
12371 case COMBODNOPUSHBLOCK: GET_COMBOCLASS_VAR_BYTE(no_push_blocks, "NoPushBlocks"); break; //C
12372 case COMBODOVERHEAD: GET_COMBOCLASS_VAR_BYTE(overhead, "Overhead"); break; //C
12373 case COMBODPLACENPC: GET_COMBOCLASS_VAR_BYTE(place_enemy, "PlaceNPC"); break; //C
12374 case COMBODPUSHDIR: GET_COMBOCLASS_VAR_BYTE(push_direction, "PushDir"); break; //C
12375 case COMBODPUSHWAIT: GET_COMBOCLASS_VAR_BYTE(push_wait, "PushDelay"); break; //C
12376 case COMBODPUSHHEAVY: GET_COMBOCLASS_VAR_BYTE(push_weight, "PushHeavy"); break; //C
12377 case COMBODPUSHED: GET_COMBOCLASS_VAR_BYTE(pushed, "Pushed"); break; //C
12378 case COMBODRAFT: GET_COMBOCLASS_VAR_BYTE(raft, "Raft"); break; //C
12379 case COMBODRESETROOM: GET_COMBOCLASS_VAR_BYTE(reset_room, "ResetRoom"); break; //C
12380 case COMBODSAVEPOINTTYPE: GET_COMBOCLASS_VAR_BYTE(save_point_type, "SavePoint"); break; //C
12381 case COMBODSCREENFREEZETYPE: GET_COMBOCLASS_VAR_BYTE(screen_freeze_type, "FreezeScreen"); break; //C
12382 case COMBODSECRETCOMBO: GET_COMBOCLASS_VAR_BYTE(secret_combo, "SecretCombo"); break; //C
12383 case COMBODSINGULAR: GET_COMBOCLASS_VAR_BYTE(singular, "Singular"); break; //C
12384 case COMBODSLOWWALK: GET_COMBOCLASS_VAR_BYTE(slow_movement, "SlowWalk"); break; //C
12385 case COMBODSTATUETYPE: GET_COMBOCLASS_VAR_BYTE(statue_type, "Statue"); break; //C
12386 case COMBODSTEPTYPE: GET_COMBOCLASS_VAR_BYTE(step_type, "Step"); break; //C
12387 case COMBODSTEPCHANGEINTO: GET_COMBOCLASS_VAR_INT(step_change_to, "StepChange"); break; //LONG
12388 case COMBODSTRIKEWEAPONS: GET_COMBOCLASS_BYTE_INDEX(strike_weapons, "Strike[]", 32); break; //BYTE, 32 INDICES.
12389 case COMBODSTRIKEREMNANTS: GET_COMBOCLASS_VAR_INT(strike_remnants, "StrikeRemnants"); break; //LONG
12390 case COMBODSTRIKEREMNANTSTYPE: GET_COMBOCLASS_VAR_BYTE(strike_remnants_type, "StrikeRemnantsType"); break; //C
12391 case COMBODSTRIKECHANGE: GET_COMBOCLASS_VAR_INT(strike_change, "StrikeChange"); break; //LONG
12392 case COMBODSTRIKEITEM: GET_COMBOCLASS_VAR_DWORD(strike_item, "StrikeItem"); break; //SHORT
12393 case COMBODTOUCHITEM: GET_COMBOCLASS_VAR_DWORD(touch_item, "TouchItem"); break; //SHORT
12394 case COMBODTOUCHSTAIRS: GET_COMBOCLASS_VAR_BYTE(touch_stairs, "TouchStairs"); break; //C
12395 case COMBODTRIGGERTYPE: GET_COMBOCLASS_VAR_BYTE(trigger_type, "TriggerType"); break; //C
12396 case COMBODTRIGGERSENS: GET_COMBOCLASS_VAR_BYTE(trigger_sensitive, "TriggerSensitivity"); break; //C
12397 case COMBODWARPTYPE: GET_COMBOCLASS_VAR_BYTE(warp_type, "Warp"); break; //C
12398 case COMBODWARPSENS: GET_COMBOCLASS_VAR_BYTE(warp_sensitive, "WarpSensitivity"); break; //C
12399 case COMBODWARPDIRECT: GET_COMBOCLASS_VAR_BYTE(warp_direct, "WarpDirect"); break; //C
12400 case COMBODWARPLOCATION: GET_COMBOCLASS_VAR_BYTE(warp_location, "WarpLocation"); break; //C
12401 case COMBODWATER: GET_COMBOCLASS_VAR_BYTE(water, "Liquid"); break; //C
12402 case COMBODWHISTLE: GET_COMBOCLASS_VAR_BYTE(whistle, "Whistle"); break; //C
12403 case COMBODWINGAME: GET_COMBOCLASS_VAR_BYTE(win_game, "WinGame"); break; //C
12404 case COMBODBLOCKWPNLEVEL: GET_COMBOCLASS_VAR_BYTE(block_weapon_lvl, "BlockWeaponLevel"); break; //C
12405
12406
12407
12408 ///----------------------------------------------------------------------------------------------------//
12409 //npcdata nd-> variables
12410
12411 //npcdata nd->member variable
12412 #define GET_NPCDATA_VAR_INT32(member, str) \
12413 { \
12414 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12415 { \
12416 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12417 ret = -10000; \
12418 } \
12419 else \
12420 { \
12421 ret = (guysbuf[ri->npcdataref].member *10000); \
12422 } \
12423 } \
12424
12425 #define GET_NPCDATA_VAR_BYTE(member, str) \
12426 { \
12427 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12428 { \
12429 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12430 ret = -10000; \
12431 } \
12432 else \
12433 { \
12434 ret = (guysbuf[ri->npcdataref].member *10000); \
12435 } \
12436 } \
12437
12438 #define GET_NPCDATA_VAR_INT16(member, str) \
12439 { \
12440 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12441 { \
12442 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12443 ret = -10000; \
12444 } \
12445 else \
12446 { \
12447 ret = (guysbuf[ri->npcdataref].member *10000); \
12448 } \
12449 } \
12450
12451 #define GET_NPCDATA_VAR_INDEX(member, str, indexbound) \
12452 { \
12453 int32_t indx = ri->d[rINDEX] / 10000; \
12454 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12455 { \
12456 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12457 ret = -10000; \
12458 } \
12459 else if ( (unsigned)indx > indexbound ) \
12460 { \
12461 Z_scripterrlog("Invalid Array Index passed to npcdata->%s: %d\n", str, indx); \
12462 ret = -10000; \
12463 } \
12464 else \
12465 { \
12466 ret = (guysbuf[ri->npcdataref].member[indx] * 10000); \
12467 } \
12468 }
12469
12470 #define GET_NPCDATA_BYTE_INDEX(member, str, indexbound) \
12471 { \
12472 int32_t indx = ri->d[rINDEX] / 10000; \
12473 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12474 { \
12475 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12476 ret = -10000; \
12477 } \
12478 else if ( (unsigned)indx > indexbound ) \
12479 { \
12480 Z_scripterrlog("Invalid Array Index passed to npcdata->%s: %d\n", str, indx); \
12481 ret = -10000; \
12482 } \
12483 else \
12484 { \
12485 ret = (guysbuf[ri->npcdataref].member[indx] * 100000); \
12486 } \
12487 }
12488
12489 #define GET_NPCDATA_FLAG(member, str, indexbound) \
12490 { \
12491 int32_t flag = (value/10000); \
12492 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12493 { \
12494 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12495 } \
12496 else \
12497 { \
12498 ret = (guysbuf[ID].member&flag) ? 10000 : 0); \
12499 } \
12500 } \
12501
12502 case NPCDATATILE: GET_NPCDATA_VAR_BYTE(tile, "Tile"); break;
12503 case NPCDATAWIDTH: GET_NPCDATA_VAR_BYTE(width, "Width"); break;
12504 case NPCDATAHEIGHT: GET_NPCDATA_VAR_BYTE(height, "Height"); break;
12505 case NPCDATAFLAGS: GET_NPCDATA_VAR_INT16(flags, "Flags"); break; //16 b its
12506 case NPCDATAFLAGS2: GET_NPCDATA_VAR_INT16(flags2, "Flags2"); break; //16 bits
12507 case NPCDATASTILE: GET_NPCDATA_VAR_BYTE(s_tile, "STile"); break;
12508 case NPCDATASWIDTH: GET_NPCDATA_VAR_BYTE(s_width, "SWidth"); break;
12509 case NPCDATASHEIGHT: GET_NPCDATA_VAR_BYTE(s_height, "SHeight"); break;
12510 case NPCDATAETILE: GET_NPCDATA_VAR_INT32(e_tile, "ExTile"); break;
12511 case NPCDATAEWIDTH: GET_NPCDATA_VAR_BYTE(e_width, "ExWidth"); break;
12512 case NPCDATAEHEIGHT: GET_NPCDATA_VAR_BYTE(e_height, "ExHeight"); break;
12513 case NPCDATAHP: GET_NPCDATA_VAR_INT16(hp, "HP"); break;
12514 case NPCDATAFAMILY: GET_NPCDATA_VAR_INT16(family, "Family"); break;
12515 case NPCDATACSET: GET_NPCDATA_VAR_INT16(cset, "CSet"); break;
12516 case NPCDATAANIM: GET_NPCDATA_VAR_INT16(anim, "Anim"); break;
12517 case NPCDATAEANIM: GET_NPCDATA_VAR_INT16(e_anim, "ExAnim"); break;
12518 case NPCDATAFRAMERATE: GET_NPCDATA_VAR_INT16(frate, "Framerate"); break;
12519 case NPCDATAEFRAMERATE: GET_NPCDATA_VAR_INT16(e_frate, "ExFramerate"); break;
12520 case NPCDATATOUCHDAMAGE: GET_NPCDATA_VAR_INT16(dp, "TouchDamage"); break;
12521 case NPCDATAWEAPONDAMAGE: GET_NPCDATA_VAR_INT16(wdp, "WeaponDamage"); break;
12522 case NPCDATAWEAPON: GET_NPCDATA_VAR_INT16(weapon, "Weapon"); break;
12523 case NPCDATARANDOM: GET_NPCDATA_VAR_INT16(rate, "Random"); break;
12524 case NPCDATAHALT: GET_NPCDATA_VAR_INT16(hrate, "Haltrate"); break;
12525 case NPCDATASTEP: GET_NPCDATA_VAR_INT16(step, "Step"); break;
12526 case NPCDATAHOMING: GET_NPCDATA_VAR_INT16(homing, "Homing"); break;
12527 case NPCDATAHUNGER: GET_NPCDATA_VAR_INT16(grumble, "Hunger"); break;
12528 case NPCDATADROPSET: GET_NPCDATA_VAR_INT16(item_set, "Dropset"); break;
12529 case NPCDATABGSFX: GET_NPCDATA_VAR_INT16(bgsfx, "BGSFX"); break;
12530 case NPCDATADEATHSFX: GET_NPCDATA_VAR_BYTE(deadsfx, "DeathSFX"); break;
12531 case NPCDATAHITSFX: GET_NPCDATA_VAR_BYTE(hitsfx, "HitSFX"); break;
12532 case NPCDATAXOFS: GET_NPCDATA_VAR_INT32(xofs, "DrawXOffset"); break;
12533 case NPCDATAYOFS: GET_NPCDATA_VAR_INT32(yofs, "DrawYOffset"); break;
12534 case NPCDATAZOFS: GET_NPCDATA_VAR_INT32(zofs, "DrawZOffset"); break;
12535 case NPCDATAHXOFS: GET_NPCDATA_VAR_INT32(hxofs, "HitXOffset"); break;
12536 case NPCDATAHYOFS: GET_NPCDATA_VAR_INT32(hyofs, "HitYOffset"); break;
12537 case NPCDATAHITWIDTH: GET_NPCDATA_VAR_INT32(hxsz, "HitWidth"); break;
12538 case NPCDATAHITHEIGHT: GET_NPCDATA_VAR_INT32(hysz, "HitHeight"); break;
12539 case NPCDATAHITZ: GET_NPCDATA_VAR_INT32(hzsz, "HitZHeight"); break;
12540 case NPCDATASCRIPT: GET_NPCDATA_VAR_INT32(script, "Script"); break;
12541 case NPCDATATILEWIDTH: GET_NPCDATA_VAR_INT32(txsz, "TileWidth"); break;
12542 case NPCDATATILEHEIGHT: GET_NPCDATA_VAR_INT32(tysz, "TileHeight"); break;
12543 case NPCDATAWPNSPRITE: GET_NPCDATA_VAR_INT32(wpnsprite, "WeaponSprite"); break;
12544 case NPCDATAWEAPONSCRIPT: GET_NPCDATA_VAR_INT32(weaponscript, "WeaponScript"); break;
12545 case NPCDATADEFENSE: GET_NPCDATA_VAR_INDEX(defense, "Defense", 42); break;
12546 case NPCDATAINITD: GET_NPCDATA_VAR_INDEX(initD, "InitD", 8); break;
12547 case NPCDATAWEAPONINITD: GET_NPCDATA_VAR_INDEX(weap_initiald, "WeaponInitD", 8); break;
12548 case NPCDATASIZEFLAG: GET_NPCDATA_VAR_INT32(SIZEflags, "SizeFlags"); break;
12549
12550 case NPCDATAFROZENTILE: GET_NPCDATA_VAR_INT32(frozentile, "FrozenTile"); break;
12551 case NPCDATAFROZENCSET: GET_NPCDATA_VAR_INT32(frozencset, "FrozenCSet"); break;
12552
12553
12554 case NPCDATAATTRIBUTE:
12555 {
12556 int32_t indx = ri->d[rINDEX] / 10000;
12557 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
12558 {
12559 Z_scripterrlog("Invalid Sprite ID passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
12560 ret = -10000;
12561 }
12562 else if ( indx < 0 || indx > MAX_NPC_ATRIBUTES )
12563 {
12564 Z_scripterrlog("Invalid Array Index passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
12565 ret = -10000;
12566 }
12567 else
12568 {
12569 switch(indx)
12570 {
12571 case 0: ret = (guysbuf[ri->npcdataref].misc1 * 10000); break;
12572 case 1: ret = (guysbuf[ri->npcdataref].misc2 * 10000); break;
12573 case 2: ret = (guysbuf[ri->npcdataref].misc3 * 10000); break;
12574 case 3: ret = (guysbuf[ri->npcdataref].misc4 * 10000); break;
12575 case 4: ret = (guysbuf[ri->npcdataref].misc5 * 10000); break;
12576 case 5: ret = (guysbuf[ri->npcdataref].misc6 * 10000); break;
12577 case 6: ret = (guysbuf[ri->npcdataref].misc7 * 10000); break;
12578 case 7: ret = (guysbuf[ri->npcdataref].misc8 * 10000); break;
12579 case 8: ret = (guysbuf[ri->npcdataref].misc9 * 10000); break;
12580 case 9: ret = (guysbuf[ri->npcdataref].misc10 * 10000); break;
12581 case 10: ret = (guysbuf[ri->npcdataref].misc11 * 10000); break;
12582 case 11: ret = (guysbuf[ri->npcdataref].misc12 * 10000); break;
12583 case 12: ret = (guysbuf[ri->npcdataref].misc13 * 10000); break;
12584 case 13: ret = (guysbuf[ri->npcdataref].misc14 * 10000); break;
12585 case 14: ret = (guysbuf[ri->npcdataref].misc15 * 10000); break;
12586 case 15: ret = (guysbuf[ri->npcdataref].misc16 * 10000); break;
12587 case 16: ret = (guysbuf[ri->npcdataref].misc17 * 10000); break;
12588 case 17: ret = (guysbuf[ri->npcdataref].misc18* 10000); break;
12589 case 18: ret = (guysbuf[ri->npcdataref].misc19 * 10000); break;
12590 case 19: ret = (guysbuf[ri->npcdataref].misc20 * 10000); break;
12591 case 20: ret = (guysbuf[ri->npcdataref].misc21 * 10000); break;
12592 case 21: ret = (guysbuf[ri->npcdataref].misc22 * 10000); break;
12593 case 22: ret = (guysbuf[ri->npcdataref].misc23 * 10000); break;
12594 case 23: ret = (guysbuf[ri->npcdataref].misc24 * 10000); break;
12595 case 24: ret = (guysbuf[ri->npcdataref].misc25 * 10000); break;
12596 case 25: ret = (guysbuf[ri->npcdataref].misc26 * 10000); break;
12597 case 26: ret = (guysbuf[ri->npcdataref].misc27 * 10000); break;
12598 case 27: ret = (guysbuf[ri->npcdataref].misc28 * 10000); break;
12599 case 28: ret = (guysbuf[ri->npcdataref].misc29 * 10000); break;
12600 case 29: ret = (guysbuf[ri->npcdataref].misc30 * 10000); break;
12601 case 30: ret = (guysbuf[ri->npcdataref].misc31 * 10000); break;
12602 case 31: ret = (guysbuf[ri->npcdataref].misc32 * 10000); break;
12603
12604
12605
12606 default:
12607 {
12608 Z_scripterrlog("Invalid Array Index passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
12609 ret = -10000;
12610 break;
12611 }
12612 }
12613
12614 }
12615 break;
12616 }
12617
12618 case NPCDATABEHAVIOUR:
12619 {
12620 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
12621 {
12622 ret = -10000;
12623 break;
12624 }
12625 int32_t index = vbound(ri->d[rINDEX]/10000,0,4);
12626 switch(index)
12627 {
12628 case 0:
12629 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG1)?10000:0; break;
12630 case 1:
12631 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG2)?10000:0; break;
12632 case 2:
12633 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG3)?10000:0; break;
12634 case 3:
12635 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG4)?10000:0; break;
12636 case 4:
12637 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG5)?10000:0; break;
12638 case 5:
12639 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG6)?10000:0; break;
12640 case 6:
12641 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG7)?10000:0; break;
12642 case 7:
12643 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG8)?10000:0; break;
12644 case 8:
12645 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG9)?10000:0; break;
12646 case 9:
12647 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG10)?10000:0; break;
12648 case 10:
12649 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG11)?10000:0; break;
12650 case 11:
12651 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG12)?10000:0; break;
12652 case 12:
12653 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG13)?10000:0; break;
12654 case 13:
12655 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG14)?10000:0; break;
12656 case 14:
12657 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG15)?10000:0; break;
12658 case 15:
12659 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG16)?10000:0; break;
12660
12661
12662 default:
12663 ret = 0; break;
12664 }
12665
12666 break;
12667 }
12668
12669 case NPCDATASHIELD:
12670 {
12671 int32_t indx = ri->d[rINDEX] / 10000;
12672 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
12673 {
12674 Z_scripterrlog("Invalid NPC ID passed to npcdata->Shield[]: %d\n", (ri->npcdataref*10000));
12675 ret = -10000;
12676 break;
12677 }
12678 else
12679 {
12680 switch(indx)
12681 {
12682 case 0:
12683 {
12684 ret = ((guysbuf[ri->npcdataref].flags&inv_front) ? 10000 : 0);
12685 break;
12686 }
12687 case 1:
12688 {
12689 ret = ((guysbuf[ri->npcdataref].flags&inv_left) ? 10000 : 0);
12690 break;
12691 }
12692 case 2:
12693 {
12694 ret = ((guysbuf[ri->npcdataref].flags&inv_right) ? 10000 : 0);
12695 break;
12696 }
12697 case 3:
12698 {
12699 ret = ((guysbuf[ri->npcdataref].flags&inv_back) ? 10000 : 0);
12700 break;
12701 }
12702 case 4:
12703 {
12704 ret = ((guysbuf[ri->npcdataref].flags&guy_bkshield) ? 10000 : 0);
12705 break;
12706 }
12707 default:
12708 {
12709 Z_scripterrlog("Invalid Array Index passed to npcdata->Shield[]: %d\n", indx);
12710 ret = -10000;
12711 break;
12712 }
12713 }
12714 }
12715 }
12716 break;
12717
12718 case NPCDSHADOWSPR:
12719 {
12720 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
12721 {
12722 Z_scripterrlog("Invalid NPC ID passed to npcdata->ShadowSprite: %d\n", (ri->npcdataref*10000));
12723 ret = -10000;
12724 }
12725 else
12726 {
12727 ret = guysbuf[ri->npcdataref].spr_shadow * 10000;
12728 }
12729 break;
12730 }
12731 case NPCDSPAWNSPR:
12732 {
12733 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
12734 {
12735 Z_scripterrlog("Invalid NPC ID passed to npcdata->SpawnSprite: %d\n", (ri->npcdataref*10000));
12736 ret = -10000;
12737 }
12738 else
12739 {
12740 ret = guysbuf[ri->npcdataref].spr_spawn * 10000;
12741 }
12742 break;
12743 }
12744 case NPCDDEATHSPR:
12745 {
12746 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
12747 {
12748 Z_scripterrlog("Invalid NPC ID passed to npcdata->DeathSprite: %d\n", (ri->npcdataref*10000));
12749 ret = -10000;
12750 }
12751 else
12752 {
12753 ret = guysbuf[ri->npcdataref].spr_death * 10000;
12754 }
12755 break;
12756 }
12757
12758 case NPCMATCHINITDLABEL: //Same form as SetScreenD()
12759 //bool npcdata->MatchInitDLabel("label", d)
12760 {
12761
12762 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12763 {
12764 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), "MatchInitDLabel()");
12765 ret = 0;
12766 break;
12767 }
12768
12769 int32_t arrayptr = get_register(sarg1) / 10000;
12770 int32_t init_d_index = get_register(sarg2) / 10000;
12771
12772 string name;
12773 ArrayH::getString(arrayptr, name, 256); // What's the limit on name length?
12774
12775 bool match = (!( strcmp(name.c_str(), guysbuf[ri->npcdataref].initD_label[init_d_index] )));
12776
12777 ret = ( match ? 10000 : 0 );
12778 break;
12779 }
12780
12781 ///----------------------------------------------------------------------------------------------------//
12782 //Dropset Variables
12783
12784 case DROPSETITEMS:
12785 {
12786 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
12787 {
12788 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
12789 ret = -10000;
12790 break;
12791 }
12792 int32_t indx = ri->d[rINDEX]/10000;
12793 if(indx < 0 || indx > 9)
12794 {
12795 Z_scripterrlog("Invalid index passed to dropdata->Items[]: %d\n", indx);
12796 ret = -10000;
12797 }
12798 else
12799 {
12800 ret = item_drop_sets[ri->dropsetref].item[indx] * 10000;
12801 }
12802 break;
12803 }
12804 case DROPSETCHANCES:
12805 {
12806 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
12807 {
12808 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
12809 ret = -10000;
12810 break;
12811 }
12812 int32_t indx = ri->d[rINDEX]/10000;
12813 if(indx < 0 || indx > 9)
12814 {
12815 Z_scripterrlog("Invalid index passed to dropdata->Chances[]: %d\n", indx);
12816 ret = -10000;
12817 }
12818 else
12819 {
12820 ret = item_drop_sets[ri->dropsetref].chance[indx+1] * 10000; //+1 is because '0' is 'nothing''s chance
12821 }
12822 break;
12823 }
12824 case DROPSETNULLCHANCE:
12825 {
12826 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
12827 {
12828 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
12829 ret = -10000;
12830 break;
12831 }
12832 ret = item_drop_sets[ri->dropsetref].chance[0] * 10000;
12833 break;
12834 }
12835 case DROPSETCHOOSE:
12836 {
12837 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
12838 {
12839 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
12840 ret = -10000;
12841 break;
12842 }
12843 ret = select_dropitem(ri->dropsetref) * 10000;
12844 break;
12845 }
12846
12847 ///----------------------------------------------------------------------------------------------------//
12848 //Audio Variables
12849
12850 case AUDIOVOLUME:
12851 {
12852 int32_t indx = ri->d[rINDEX] / 10000;
12853 switch(indx)
12854 {
12855
12856 case 0: //midi volume
12857 {
12858 ret = FFScript::do_getMIDI_volume() * 10000;
12859 break;
12860 }
12861 case 1: //digi volume
12862 {
12863 ret = FFScript::do_getDIGI_volume() * 10000;
12864 break;
12865 }
12866 case 2: //emh music volume
12867 {
12868 ret = FFScript::do_getMusic_volume() * 10000;
12869 break;
12870 }
12871 case 3: //sfx volume
12872 {
12873 ret = FFScript::do_getSFX_volume() * 10000;
12874 break;
12875 }
12876 default:
12877 {
12878 Z_scripterrlog("Attempted to access an invalid index of Audio->Volume[]", indx);
12879 ret = -10000;
12880 break;
12881 }
12882 }
12883 }
12884 break;
12885
12886 case AUDIOPAN:
12887 {
12888 ret = FFScript::do_getSFX_pan() * 10000;
12889 break;
12890 }
12891
12892 ///----------------------------------------------------------------------------------------------------//
12893 //Graphics->
12894
12895 case NUMDRAWS:
12896 ret = script_drawing_commands.Count() * 10000;
12897 //ret = FFCore.numscriptdraws * 10000; // This isn't updated until end of frame, making it useless!
12898 break;
12899
12900 case MAXDRAWS:
12901 ret = MAX_SCRIPT_DRAWING_COMMANDS * 10000;
12902 break;
12903
12904 case ISBLANKTILE: ret = (FFCore.IsBlankTile(ri->d[rINDEX]/10000) * 10000); break;
12905
12906 case BITMAPWIDTH:
12907 {
12908 //if ( scb.script_created_bitmaps[ri->bitmapref].u_bmp )
12909 //{
12910 // ret = scb.script_created_bitmaps[ri->bitmapref].u_bmp->w * 10000;
12911 //}
12912 //else ret = 0;
12913 ret = scb.script_created_bitmaps[ri->bitmapref-10].width * 10000;
12914 break;
12915 }
12916
12917 case BITMAPHEIGHT:
12918 {
12919 //Z_scripterrlog("BITMAPHEI|GHT ri->BitmapRef is %d\n", ri->bitmapref);
12920 //Z_scripterrlog("ref bitmap height: %d\n", scb.script_created_bitmaps[ri->bitmapref-10].u_bmp->h);
12921 //if ( scb.script_created_bitmaps[ri->bitmapref].u_bmp )
12922 //{
12923 // ret = scb.script_created_bitmaps[ri->bitmapref].u_bmp->h * 10000;
12924 //}
12925 //else ret = 0;
12926 ret = scb.script_created_bitmaps[ri->bitmapref-10].height * 10000;
12927 break;
12928 }
12929 ///----------------------------------------------------------------------------------------------------//
12930 //File->
12931 case FILEPOS:
12932 {
12933 if(user_file* f = checkFile(ri->fileref, "Pos", true))
12934 {
12935 ret = ftell(f->file); //NOT *10000 -V
12936 }
12937 else ret = -10000L;
12938 break;
12939 }
12940 case FILEEOF:
12941 {
12942 if(user_file* f = checkFile(ri->fileref, "EOF", true))
12943 {
12944 ret = feof(f->file) ? 10000L : 0L; //Boolean
12945 }
12946 else ret = -10000L;
12947 break;
12948 }
12949 case FILEERR:
12950 {
12951 if(user_file* f = checkFile(ri->fileref, "Error", true))
12952 {
12953 ret = ferror(f->file) * 10000L;
12954 }
12955 else ret = -10000L;
12956 break;
12957 }
12958
12959 ///----------------------------------------------------------------------------------------------------//
12960 //Directory->
12961 case DIRECTORYSIZE:
12962 {
12963 if(user_dir* dr = checkDir(ri->directoryref, "Size()", true))
12964 {
12965 ret = dr->size() * 10000L;
12966 }
12967 else ret = -10000L;
12968 break;
12969 }
12970
12971 ///----------------------------------------------------------------------------------------------------//
12972 //Stack->
12973 case STACKSIZE:
12974 {
12975 if(user_stack* st = checkStack(ri->stackref, "Size", true))
12976 {
12977 ret = st->size(); //NOT *10000
12978 }
12979 else ret = -10000L;
12980 break;
12981 }
12982 case STACKFULL:
12983 {
12984 if(user_stack* st = checkStack(ri->stackref, "Full", true))
12985 {
12986 ret = st->full() ? 10000L : 0L;
12987 }
12988 else ret = -10000L;
12989 break;
12990 }
12991
12992 ///----------------------------------------------------------------------------------------------------//
12993 //Module->
12994
12995 case MODULEGETINT:
12996 {
12997 int32_t section_pointer = ((ri->d[rINDEX])/10000);
12998 int32_t element_pointer = ((ri->d[rINDEX2])/10000);
12999 string sectionid;
13000 string elementid;
13001
13002 ArrayH::getString(section_pointer, sectionid);
13003 ArrayH::getString(element_pointer, elementid);
13004
13005 ///set config file
13006 if(!fileexists((char*)moduledata.module_name))
13007 {
13008 Z_scripterrlog("I/O Error: No module definitions found when using Module->GetInt()\n");
13009 ret = -10000;
13010 }
13011 else
13012 {
13013 zc_push_config();
13014 zc_config_file(moduledata.module_name);
13015 ret = zc_get_config_basic(sectionid.c_str(), elementid.c_str(), 0)*10000;
13016 //return config file to zc.cfg
13017 zc_pop_config();
13018 }
13019 break;
13020 }
13021
13022 ///----------------------------------------------------------------------------------------------------//
13023 //Misc./Internal
13024 case REFFFC:
13025 15656 ret = ri->ffcref * 10000;
13026 15656 break;
13027
13028 case REFITEM:
13029 158257 ret = ri->itemref;
13030 158257 break;
13031
13032 case REFITEMCLASS:
13033 1817944 ret = ri->idata;
13034 1817944 break;
13035
13036 case REFLWPN:
13037 1340238 ret = ri->lwpn;
13038 1340238 break;
13039
13040 case REFEWPN:
13041 2886839 ret = ri->ewpn;
13042 2886839 break;
13043
13044 case REFNPC:
13045 15644160 ret = ri->guyref;
13046 15644160 break;
13047
13048 case REFMAPDATA: ret = ri->mapsref; break;
13049 case REFSCREENDATA: ret = ri->screenref; break;
13050 25786 case REFCOMBODATA: ret = ri->combosref; break;
13051 16 case REFSPRITEDATA: ret = ri->spritesref; break;
13052 case REFBITMAP: ret = ri->bitmapref; break;
13053 case REFNPCCLASS: ret = ri->npcdataref; break;
13054
13055
13056 800741 case REFDMAPDATA: ret = ri->dmapsref; break;
13057 case REFSHOPDATA: ret = ri->shopsref; break;
13058 case REFMSGDATA: ret = ri->zmsgref; break;
13059 case REFUNTYPED: ret = ri->untypedref; break;
13060
13061 case REFDROPS: ret = ri->dropsetref; break;
13062 case REFBOTTLETYPE: ret = ri->bottletyperef; break;
13063 case REFBOTTLESHOP: ret = ri->bottleshopref; break;
13064 427 case REFGENERICDATA: ret = ri->genericdataref; break;
13065 case REFPONDS: ret = ri->pondref; break;
13066 case REFWARPRINGS: ret = ri->warpringref; break;
13067 case REFDOORS: ret = ri->doorsref; break;
13068 case REFUICOLOURS: ret = ri->zcoloursref; break;
13069 case REFRGB: ret = ri->rgbref; break;
13070 case REFPALETTE: ret = ri->paletteref; break;
13071 case REFTUNES: ret = ri->tunesref; break;
13072 case REFPALCYCLE: ret = ri->palcycleref; break;
13073 case REFGAMEDATA: ret = ri->gamedataref; break;
13074 case REFCHEATS: ret = ri->cheatsref; break;
13075 case REFFILE: ret = ri->fileref; break;
13076 case REFDIRECTORY: ret = ri->directoryref; break;
13077 case REFSTACK: ret = ri->stackref; break;
13078 case REFSUBSCREEN: ret = ri->subscreenref; break;
13079 case REFRNG: ret = ri->rngref; break;
13080 case CLASS_THISKEY: ret = ri->thiskey; break;
13081 case CLASS_THISKEY2: ret = ri->thiskey2; break;
13082 case REFPALDATA: ret = ri->paldataref; break;
13083
13084
13085 case SP:
13086 ret = ri->sp * 10000;
13087 break;
13088
13089 case PC:
13090 ret = ri->pc;
13091 break;
13092
13093 case SWITCHKEY:
13094 ret = ri->switchkey;
13095 break;
13096
13097 case SCRIPTRAM:
13098 case GLOBALRAM:
13099 952310006 ret = ArrayH::getElement(ri->d[rINDEX] / 10000, ri->d[rINDEX2] / 10000);
13100 952310006 break;
13101
13102 case SCRIPTRAMD:
13103 case GLOBALRAMD:
13104 ret = ArrayH::getElement(ri->d[rINDEX] / 10000, 0);
13105 break;
13106
13107 case GDD://Doesn't work like this =(
13108 ret = game->global_d[ri->d[rINDEX] / 10000];
13109 break;
13110
13111 ///----------------------------------------------------------------------------------------------------//
13112
13113 case PALDATACOLOR:
13114 {
13115 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->GetColor()"))
13116 {
13117 int32_t ind = ri->d[rINDEX] / 10000; // get_register(sarg1) / 10000;
13118 if (unsigned(ind) >= PALDATA_NUM_COLORS)
13119 {
13120 Z_scripterrlog("Invalid color index (%d) passed to paldata->GetColor(). Valid indices are 0-255.\n", ind);
13121 ret = -10000;
13122 break;
13123 }
13124
13125 if (get_bit(pd->colors_used, ind))
13126 {
13127 RGB c = pd->colors[ind];
13128
13129 ret = (c.r << 16) | (c.g << 8) | c.b;
13130 }
13131 else
13132 {
13133 //Z_scripterrlog("Color index (%d) returned an invalid color in paldata->GetColor().\n", ind);
13134 ret = -10000;
13135 break;
13136 }
13137 }
13138 break;
13139 }
13140 case PALDATAR:
13141 ret = FFCore.do_paldata_getrgb(0);
13142 break;
13143 case PALDATAG:
13144 ret = FFCore.do_paldata_getrgb(1);
13145 break;
13146 case PALDATAB:
13147 ret = FFCore.do_paldata_getrgb(2);
13148 break;
13149
13150 ///----------------------------------------------------------------------------------------------------//
13151
13152 case GENDATARUNNING:
13153 {
13154 ret = 0;
13155 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "Running"))
13156 {
13157 ret = scr->doscript ? 10000L : 0L;
13158 }
13159 break;
13160 }
13161 case GENDATASIZE:
13162 {
13163 ret = 0;
13164 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "DataSize"))
13165 {
13166 ret = scr->dataSize()*10000;
13167 }
13168 break;
13169 }
13170 case GENDATAEXITSTATE:
13171 {
13172 ret = 0;
13173 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "ExitState"))
13174 {
13175 size_t indx = ri->d[rINDEX]/10000;
13176 if(indx >= GENSCR_NUMST)
13177 {
13178 Z_scripterrlog("Invalid index passed to genericdata->ExitState[]: %d\n", indx);
13179 break;
13180 }
13181 ret = (scr->exitState & (1<<indx)) ? 10000L : 0;
13182 }
13183 break;
13184 }
13185 case GENDATARELOADSTATE:
13186 {
13187 ret = 0;
13188 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "ReloadState"))
13189 {
13190 size_t indx = ri->d[rINDEX]/10000;
13191 if(indx >= GENSCR_NUMST)
13192 {
13193 Z_scripterrlog("Invalid index passed to genericdata->ReloadState[]: %d\n", indx);
13194 break;
13195 }
13196 ret = (scr->reloadState & (1<<indx)) ? 10000L : 0;
13197 }
13198 break;
13199 }
13200 case GENDATAEVENTSTATE:
13201 {
13202 ret = 0;
13203 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "EventListen"))
13204 {
13205 size_t indx = ri->d[rINDEX]/10000;
13206 if(indx >= GENSCR_NUMEVENT)
13207 {
13208 Z_scripterrlog("Invalid index passed to genericdata->EventListen[]: %d\n", indx);
13209 break;
13210 }
13211 ret = (scr->eventstate & (1<<indx)) ? 10000L : 0;
13212 }
13213 break;
13214 }
13215 case GENDATADATA:
13216 {
13217 ret = 0;
13218 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "Data[]"))
13219 {
13220 size_t indx = ri->d[rINDEX]/10000;
13221 if(indx >= scr->dataSize())
13222 {
13223 Z_scripterrlog("Invalid index passed to genericdata->Data[]: %d\n", indx);
13224 break;
13225 }
13226 ret = scr->data[indx];
13227 }
13228 break;
13229 }
13230 case GENDATAINITD:
13231 {
13232 ret = 0;
13233 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "InitD[]"))
13234 {
13235 size_t indx = ri->d[rINDEX]/10000;
13236 if(indx >= 8)
13237 {
13238 Z_scripterrlog("Invalid index passed to genericdata->InitD[]: %d\n", indx);
13239 break;
13240 }
13241 ret = scr->initd[indx];
13242 }
13243 break;
13244 }
13245
13246 ///----------------------------------------------------------------------------------------------------//
13247
13248 case PORTALX:
13249 {
13250 ret = -10000;
13251 if(portal* p = checkPortal(ri->portalref, "X"))
13252 ret = p->x.getZLong();
13253 break;
13254 }
13255 case PORTALY:
13256 {
13257 ret = -10000;
13258 if(portal* p = checkPortal(ri->portalref, "Y"))
13259 ret = p->y.getZLong();
13260 break;
13261 }
13262 case PORTALDMAP:
13263 {
13264 ret = -10000;
13265 if(portal* p = checkPortal(ri->portalref, "DMap"))
13266 ret = p->destdmap*10000;
13267 break;
13268 }
13269 case PORTALSCREEN:
13270 {
13271 ret = -10000;
13272 if(portal* p = checkPortal(ri->portalref, "Screen"))
13273 ret = p->destscr*10000;
13274 break;
13275 }
13276 case PORTALACLK:
13277 {
13278 ret = -10000;
13279 if(portal* p = checkPortal(ri->portalref, "AClk"))
13280 ret = p->aclk*10000;
13281 break;
13282 }
13283 case PORTALAFRM:
13284 {
13285 ret = -10000;
13286 if(portal* p = checkPortal(ri->portalref, "AFrame"))
13287 ret = p->aframe*10000;
13288 break;
13289 }
13290 case PORTALOTILE:
13291 {
13292 ret = -10000;
13293 if(portal* p = checkPortal(ri->portalref, "OriginalTile"))
13294 ret = p->o_tile*10000;
13295 break;
13296 }
13297 case PORTALASPD:
13298 {
13299 ret = -10000;
13300 if(portal* p = checkPortal(ri->portalref, "ASpeed"))
13301 ret = p->aspd*10000;
13302 break;
13303 }
13304 case PORTALFRAMES:
13305 {
13306 ret = -10000;
13307 if(portal* p = checkPortal(ri->portalref, "Frames"))
13308 ret = p->frames*10000;
13309 break;
13310 }
13311 case PORTALSAVED:
13312 {
13313 ret = 0;
13314 if(portal* p = checkPortal(ri->portalref, "SavedPortal"))
13315 ret = p->saved_data;
13316 break;
13317 }
13318 case PORTALCLOSEDIS:
13319 {
13320 ret = 0;
13321 if(portal* p = checkPortal(ri->portalref, "CloseDisabled"))
13322 ret = p->prox_active ? 0 : 10000; //Inverted
13323 break;
13324 }
13325 case REFPORTAL:
13326 {
13327 ret = ri->portalref;
13328 break;
13329 }
13330 case REFSAVPORTAL:
13331 {
13332 ret = ri->saveportalref;
13333 break;
13334 }
13335 case PORTALWARPSFX:
13336 {
13337 ret = 0;
13338 if(portal* p = checkPortal(ri->portalref, "WarpSFX"))
13339 ret = p->wsfx ? 0 : 10000;
13340 break;
13341 }
13342 case PORTALWARPVFX:
13343 {
13344 ret = 0;
13345 if(portal* p = checkPortal(ri->portalref, "WarpEffect"))
13346 ret = p->weffect ? 0 : 10000;
13347 break;
13348 }
13349 case SAVEDPORTALX:
13350 {
13351 ret = -10000;
13352 if(savedportal* p = checkSavedPortal(ri->saveportalref, "X"))
13353 ret = p->x;
13354 break;
13355 }
13356 case SAVEDPORTALY:
13357 {
13358 ret = -10000;
13359 if(savedportal* p = checkSavedPortal(ri->saveportalref, "Y"))
13360 ret = p->y;
13361 break;
13362 }
13363 case SAVEDPORTALSRCDMAP:
13364 {
13365 ret = -10000;
13366 if(savedportal* p = checkSavedPortal(ri->saveportalref, "SrcDMap"))
13367 ret = p->srcdmap * 10000;
13368 break;
13369 }
13370 case SAVEDPORTALDESTDMAP:
13371 {
13372 ret = -10000;
13373 if(savedportal* p = checkSavedPortal(ri->saveportalref, "DestDMap"))
13374 ret = p->destdmap * 10000;
13375 break;
13376 }
13377 case SAVEDPORTALSRCSCREEN:
13378 {
13379 ret = -10000;
13380 if(savedportal* p = checkSavedPortal(ri->saveportalref, "SrcScreen"))
13381 ret = p->srcscr * 10000;
13382 break;
13383 }
13384 case SAVEDPORTALDSTSCREEN:
13385 {
13386 ret = -10000;
13387 if(savedportal* p = checkSavedPortal(ri->saveportalref, "DestScreen"))
13388 ret = p->destscr * 10000;
13389 break;
13390 }
13391 case SAVEDPORTALWARPSFX:
13392 {
13393 ret = -10000;
13394 if(savedportal* p = checkSavedPortal(ri->saveportalref, "WarpSFX"))
13395 ret = p->sfx * 10000;
13396 break;
13397 }
13398 case SAVEDPORTALWARPVFX:
13399 {
13400 ret = -10000;
13401 if(savedportal* p = checkSavedPortal(ri->saveportalref, "WarpEffect"))
13402 ret = p->warpfx * 10000;
13403 break;
13404 }
13405 case SAVEDPORTALSPRITE:
13406 {
13407 ret = -10000;
13408 if(savedportal* p = checkSavedPortal(ri->saveportalref, "Sprite"))
13409 ret = p->spr * 10000;
13410 break;
13411 }
13412 case SAVEDPORTALPORTAL:
13413 {
13414 ret = 0;
13415 if(savedportal* p = checkSavedPortal(ri->saveportalref, "Portal"))
13416 ret = getPortalFromSaved(p);
13417 break;
13418 }
13419 case PORTALCOUNT:
13420 {
13421 ret = portals.Count()*10000;
13422 break;
13423 }
13424 case SAVEDPORTALCOUNT:
13425 {
13426 ret = game->user_portals.size()*10000;
13427 break;
13428 }
13429
13430
13431 default:
13432 {
13433
2/4
✓ Branch 0 taken 751837446 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 751837446 times.
751837446 if(arg >= D(0) && arg <= D(7)) ret = ri->d[arg - D(0)];
13434 else if(arg >= A(0) && arg <= A(1)) ret = ri->a[arg - A(0)];
13435 else if(arg >= GD(0) && arg <= GD(MAX_SCRIPT_REGISTERS)) ret = game->global_d[arg - GD(0)];
13436
13437 751837446 break;
13438 }
13439 }
13440
13441
1/2
✓ Branch 0 taken 2767179039 times.
✗ Branch 1 not taken.
2767179039 if ( zasm_debugger ) FFCore.ZASMPrintVarGet(arg, ret);
13442 2767179039 return ret;
13443 }
13444
13445 //Setter Instructions
13446
13447
13448 1401178322 void set_register(int32_t arg, int32_t value)
13449 {
13450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1401178322 times.
1401178322 if ( zasm_debugger ) FFCore.ZASMPrintVarSet(arg, value);
13451 //Macros
13452
13453 #define SET_SPRITEDATA_VAR_INT(member, str) \
13454 { \
13455 if(unsigned(ri->spritesref) > (MAXWPNS-1) ) \
13456 { \
13457 Z_scripterrlog("Invalid Sprite ID passed to spritedata->%s: %d\n", str, (ri->spritesref*10000)); \
13458 } \
13459 else \
13460 { \
13461 wpnsbuf[ri->spritesref].member = vbound((value / 10000),0,214747); \
13462 } \
13463 } \
13464
13465 #define SET_SPRITEDATA_VAR_BYTE(member, str) \
13466 { \
13467 if(unsigned(ri->spritesref) > (MAXWPNS-1) ) \
13468 { \
13469 Z_scripterrlog("Invalid Sprite ID passed to spritedata->%s: %d\n", str, (ri->spritesref*10000)); \
13470 } \
13471 else \
13472 { \
13473 wpnsbuf[ri->spritesref].member = vbound((value / 10000),0,255); \
13474 } \
13475 } \
13476
13477
246/1194
✓ Branch 0 taken 1215785 times.
✓ Branch 1 taken 9444 times.
✓ Branch 2 taken 9428 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9172 times.
✓ Branch 5 taken 3250 times.
✓ Branch 6 taken 1532 times.
✓ Branch 7 taken 56626 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 78737 times.
✓ Branch 13 taken 222649 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 787 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 2 times.
✓ Branch 23 taken 193749 times.
✓ Branch 24 taken 1469 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 4552 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 234661 times.
✓ Branch 32 taken 234074 times.
✓ Branch 33 taken 910117 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✓ Branch 36 taken 21219 times.
✓ Branch 37 taken 2612168 times.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✓ Branch 41 taken 1 times.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✓ Branch 46 taken 88964 times.
✓ Branch 47 taken 551 times.
✗ Branch 48 not taken.
✓ Branch 49 taken 131 times.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✓ Branch 62 taken 455505918 times.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✓ Branch 65 taken 261880537 times.
✗ Branch 66 not taken.
✓ Branch 67 taken 2270014 times.
✓ Branch 68 taken 9724 times.
✓ Branch 69 taken 1041229 times.
✓ Branch 70 taken 2881 times.
✓ Branch 71 taken 1213780 times.
✓ Branch 72 taken 9172 times.
✓ Branch 73 taken 229038 times.
✓ Branch 74 taken 3248 times.
✓ Branch 75 taken 9502 times.
✓ Branch 76 taken 9512 times.
✓ Branch 77 taken 616 times.
✓ Branch 78 taken 900 times.
✓ Branch 79 taken 17706 times.
✗ Branch 80 not taken.
✗ Branch 81 not taken.
✓ Branch 82 taken 444601 times.
✗ Branch 83 not taken.
✓ Branch 84 taken 458940 times.
✓ Branch 85 taken 2769 times.
✓ Branch 86 taken 64379 times.
✗ Branch 87 not taken.
✓ Branch 88 taken 93694 times.
✗ Branch 89 not taken.
✗ Branch 90 not taken.
✗ Branch 91 not taken.
✓ Branch 92 taken 270554 times.
✓ Branch 93 taken 10416 times.
✓ Branch 94 taken 56 times.
✗ Branch 95 not taken.
✓ Branch 96 taken 388 times.
✗ Branch 97 not taken.
✗ Branch 98 not taken.
✗ Branch 99 not taken.
✗ Branch 100 not taken.
✓ Branch 101 taken 5906 times.
✗ Branch 102 not taken.
✗ Branch 103 not taken.
✓ Branch 104 taken 740 times.
✗ Branch 105 not taken.
✓ Branch 106 taken 4 times.
✓ Branch 107 taken 5161 times.
✗ Branch 108 not taken.
✗ Branch 109 not taken.
✗ Branch 110 not taken.
✗ Branch 111 not taken.
✗ Branch 112 not taken.
✗ Branch 113 not taken.
✗ Branch 114 not taken.
✓ Branch 115 taken 280560 times.
✗ Branch 116 not taken.
✗ Branch 117 not taken.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✗ Branch 120 not taken.
✗ Branch 121 not taken.
✗ Branch 122 not taken.
✗ Branch 123 not taken.
✗ Branch 124 not taken.
✗ Branch 125 not taken.
✗ Branch 126 not taken.
✓ Branch 127 taken 93759 times.
✓ Branch 128 taken 93760 times.
✓ Branch 129 taken 93772 times.
✓ Branch 130 taken 93778 times.
✗ Branch 131 not taken.
✗ Branch 132 not taken.
✗ Branch 133 not taken.
✗ Branch 134 not taken.
✗ Branch 135 not taken.
✓ Branch 136 taken 2569 times.
✗ Branch 137 not taken.
✓ Branch 138 taken 2569 times.
✗ Branch 139 not taken.
✗ Branch 140 not taken.
✗ Branch 141 not taken.
✗ Branch 142 not taken.
✗ Branch 143 not taken.
✗ Branch 144 not taken.
✗ Branch 145 not taken.
✗ Branch 146 not taken.
✗ Branch 147 not taken.
✗ Branch 148 not taken.
✗ Branch 149 not taken.
✗ Branch 150 not taken.
✓ Branch 151 taken 166 times.
✗ Branch 152 not taken.
✗ Branch 153 not taken.
✗ Branch 154 not taken.
✗ Branch 155 not taken.
✗ Branch 156 not taken.
✗ Branch 157 not taken.
✗ Branch 158 not taken.
✗ Branch 159 not taken.
✗ Branch 160 not taken.
✗ Branch 161 not taken.
✗ Branch 162 not taken.
✗ Branch 163 not taken.
✗ Branch 164 not taken.
✗ Branch 165 not taken.
✗ Branch 166 not taken.
✓ Branch 167 taken 928305 times.
✓ Branch 168 taken 461908 times.
✓ Branch 169 taken 249228 times.
✓ Branch 170 taken 249220 times.
✓ Branch 171 taken 236658 times.
✓ Branch 172 taken 236880 times.
✓ Branch 173 taken 89166 times.
✓ Branch 174 taken 76223 times.
✓ Branch 175 taken 78784 times.
✓ Branch 176 taken 222649 times.
✓ Branch 177 taken 222649 times.
✓ Branch 178 taken 222649 times.
✓ Branch 179 taken 222649 times.
✗ Branch 180 not taken.
✗ Branch 181 not taken.
✗ Branch 182 not taken.
✗ Branch 183 not taken.
✓ Branch 184 taken 928305 times.
✓ Branch 185 taken 461908 times.
✓ Branch 186 taken 218369 times.
✓ Branch 187 taken 218364 times.
✓ Branch 188 taken 218431 times.
✓ Branch 189 taken 218461 times.
✓ Branch 190 taken 83086 times.
✓ Branch 191 taken 70141 times.
✓ Branch 192 taken 75869 times.
✓ Branch 193 taken 75916 times.
✓ Branch 194 taken 222649 times.
✓ Branch 195 taken 222649 times.
✓ Branch 196 taken 222649 times.
✗ Branch 197 not taken.
✗ Branch 198 not taken.
✗ Branch 199 not taken.
✗ Branch 200 not taken.
✗ Branch 201 not taken.
✗ Branch 202 not taken.
✓ Branch 203 taken 281179 times.
✓ Branch 204 taken 281265 times.
✗ Branch 205 not taken.
✗ Branch 206 not taken.
✗ Branch 207 not taken.
✗ Branch 208 not taken.
✗ Branch 209 not taken.
✗ Branch 210 not taken.
✗ Branch 211 not taken.
✗ Branch 212 not taken.
✗ Branch 213 not taken.
✗ Branch 214 not taken.
✗ Branch 215 not taken.
✓ Branch 216 taken 21848 times.
✓ Branch 217 taken 31 times.
✗ Branch 218 not taken.
✓ Branch 219 taken 41791 times.
✓ Branch 220 taken 92 times.
✓ Branch 221 taken 49959 times.
✗ Branch 222 not taken.
✗ Branch 223 not taken.
✓ Branch 224 taken 37 times.
✗ Branch 225 not taken.
✗ Branch 226 not taken.
✓ Branch 227 taken 109 times.
✗ Branch 228 not taken.
✗ Branch 229 not taken.
✗ Branch 230 not taken.
✗ Branch 231 not taken.
✗ Branch 232 not taken.
✓ Branch 233 taken 40 times.
✗ Branch 234 not taken.
✗ Branch 235 not taken.
✗ Branch 236 not taken.
✗ Branch 237 not taken.
✗ Branch 238 not taken.
✗ Branch 239 not taken.
✗ Branch 240 not taken.
✗ Branch 241 not taken.
✗ Branch 242 not taken.
✗ Branch 243 not taken.
✗ Branch 244 not taken.
✗ Branch 245 not taken.
✓ Branch 246 taken 6 times.
✗ Branch 247 not taken.
✗ Branch 248 not taken.
✗ Branch 249 not taken.
✗ Branch 250 not taken.
✗ Branch 251 not taken.
✗ Branch 252 not taken.
✗ Branch 253 not taken.
✗ Branch 254 not taken.
✓ Branch 255 taken 3013 times.
✗ Branch 256 not taken.
✗ Branch 257 not taken.
✗ Branch 258 not taken.
✗ Branch 259 not taken.
✗ Branch 260 not taken.
✓ Branch 261 taken 68 times.
✗ Branch 262 not taken.
✗ Branch 263 not taken.
✗ Branch 264 not taken.
✗ Branch 265 not taken.
✗ Branch 266 not taken.
✗ Branch 267 not taken.
✗ Branch 268 not taken.
✗ Branch 269 not taken.
✗ Branch 270 not taken.
✗ Branch 271 not taken.
✗ Branch 272 not taken.
✗ Branch 273 not taken.
✗ Branch 274 not taken.
✗ Branch 275 not taken.
✗ Branch 276 not taken.
✗ Branch 277 not taken.
✗ Branch 278 not taken.
✗ Branch 279 not taken.
✗ Branch 280 not taken.
✗ Branch 281 not taken.
✗ Branch 282 not taken.
✗ Branch 283 not taken.
✗ Branch 284 not taken.
✗ Branch 285 not taken.
✗ Branch 286 not taken.
✗ Branch 287 not taken.
✗ Branch 288 not taken.
✗ Branch 289 not taken.
✗ Branch 290 not taken.
✗ Branch 291 not taken.
✗ Branch 292 not taken.
✗ Branch 293 not taken.
✗ Branch 294 not taken.
✗ Branch 295 not taken.
✗ Branch 296 not taken.
✗ Branch 297 not taken.
✗ Branch 298 not taken.
✗ Branch 299 not taken.
✗ Branch 300 not taken.
✗ Branch 301 not taken.
✗ Branch 302 not taken.
✗ Branch 303 not taken.
✗ Branch 304 not taken.
✗ Branch 305 not taken.
✗ Branch 306 not taken.
✗ Branch 307 not taken.
✗ Branch 308 not taken.
✗ Branch 309 not taken.
✗ Branch 310 not taken.
✗ Branch 311 not taken.
✗ Branch 312 not taken.
✗ Branch 313 not taken.
✗ Branch 314 not taken.
✗ Branch 315 not taken.
✗ Branch 316 not taken.
✗ Branch 317 not taken.
✗ Branch 318 not taken.
✗ Branch 319 not taken.
✗ Branch 320 not taken.
✗ Branch 321 not taken.
✗ Branch 322 not taken.
✗ Branch 323 not taken.
✗ Branch 324 not taken.
✗ Branch 325 not taken.
✗ Branch 326 not taken.
✗ Branch 327 not taken.
✗ Branch 328 not taken.
✗ Branch 329 not taken.
✗ Branch 330 not taken.
✗ Branch 331 not taken.
✗ Branch 332 not taken.
✗ Branch 333 not taken.
✗ Branch 334 not taken.
✓ Branch 335 taken 2760 times.
✗ Branch 336 not taken.
✗ Branch 337 not taken.
✗ Branch 338 not taken.
✗ Branch 339 not taken.
✗ Branch 340 not taken.
✗ Branch 341 not taken.
✗ Branch 342 not taken.
✓ Branch 343 taken 70 times.
✗ Branch 344 not taken.
✗ Branch 345 not taken.
✗ Branch 346 not taken.
✗ Branch 347 not taken.
✗ Branch 348 not taken.
✗ Branch 349 not taken.
✗ Branch 350 not taken.
✓ Branch 351 taken 193756 times.
✗ Branch 352 not taken.
✓ Branch 353 taken 180 times.
✗ Branch 354 not taken.
✓ Branch 355 taken 65054 times.
✗ Branch 356 not taken.
✗ Branch 357 not taken.
✓ Branch 358 taken 8276 times.
✗ Branch 359 not taken.
✗ Branch 360 not taken.
✗ Branch 361 not taken.
✓ Branch 362 taken 1175 times.
✗ Branch 363 not taken.
✓ Branch 364 taken 16 times.
✓ Branch 365 taken 49 times.
✓ Branch 366 taken 69347 times.
✓ Branch 367 taken 139174 times.
✗ Branch 368 not taken.
✓ Branch 369 taken 1853 times.
✓ Branch 370 taken 3221 times.
✗ Branch 371 not taken.
✓ Branch 372 taken 2065 times.
✗ Branch 373 not taken.
✓ Branch 374 taken 404 times.
✗ Branch 375 not taken.
✓ Branch 376 taken 457 times.
✗ Branch 377 not taken.
✓ Branch 378 taken 683 times.
✓ Branch 379 taken 4922 times.
✓ Branch 380 taken 16 times.
✓ Branch 381 taken 1841 times.
✗ Branch 382 not taken.
✓ Branch 383 taken 60616 times.
✓ Branch 384 taken 60616 times.
✓ Branch 385 taken 156 times.
✓ Branch 386 taken 63470 times.
✗ Branch 387 not taken.
✗ Branch 388 not taken.
✗ Branch 389 not taken.
✗ Branch 390 not taken.
✓ Branch 391 taken 61740 times.
✓ Branch 392 taken 61757 times.
✗ Branch 393 not taken.
✓ Branch 394 taken 10 times.
✓ Branch 395 taken 10 times.
✓ Branch 396 taken 497624 times.
✓ Branch 397 taken 16120 times.
✗ Branch 398 not taken.
✗ Branch 399 not taken.
✗ Branch 400 not taken.
✓ Branch 401 taken 60902 times.
✓ Branch 402 taken 603 times.
✗ Branch 403 not taken.
✓ Branch 404 taken 238 times.
✗ Branch 405 not taken.
✗ Branch 406 not taken.
✗ Branch 407 not taken.
✗ Branch 408 not taken.
✗ Branch 409 not taken.
✓ Branch 410 taken 265 times.
✗ Branch 411 not taken.
✗ Branch 412 not taken.
✗ Branch 413 not taken.
✗ Branch 414 not taken.
✗ Branch 415 not taken.
✗ Branch 416 not taken.
✗ Branch 417 not taken.
✗ Branch 418 not taken.
✗ Branch 419 not taken.
✗ Branch 420 not taken.
✗ Branch 421 not taken.
✗ Branch 422 not taken.
✓ Branch 423 taken 226569 times.
✓ Branch 424 taken 2 times.
✓ Branch 425 taken 226856 times.
✓ Branch 426 taken 6823 times.
✓ Branch 427 taken 6048 times.
✗ Branch 428 not taken.
✓ Branch 429 taken 138270 times.
✗ Branch 430 not taken.
✗ Branch 431 not taken.
✓ Branch 432 taken 264908 times.
✓ Branch 433 taken 134925 times.
✗ Branch 434 not taken.
✗ Branch 435 not taken.
✗ Branch 436 not taken.
✓ Branch 437 taken 131702 times.
✗ Branch 438 not taken.
✓ Branch 439 taken 47 times.
✓ Branch 440 taken 12175 times.
✓ Branch 441 taken 132679 times.
✓ Branch 442 taken 23997 times.
✗ Branch 443 not taken.
✓ Branch 444 taken 9747 times.
✗ Branch 445 not taken.
✗ Branch 446 not taken.
✓ Branch 447 taken 2072 times.
✗ Branch 448 not taken.
✓ Branch 449 taken 41 times.
✗ Branch 450 not taken.
✓ Branch 451 taken 41 times.
✓ Branch 452 taken 549 times.
✓ Branch 453 taken 49622 times.
✓ Branch 454 taken 1104 times.
✓ Branch 455 taken 111461 times.
✗ Branch 456 not taken.
✓ Branch 457 taken 138269 times.
✓ Branch 458 taken 137776 times.
✓ Branch 459 taken 35370 times.
✓ Branch 460 taken 38448 times.
✗ Branch 461 not taken.
✗ Branch 462 not taken.
✗ Branch 463 not taken.
✓ Branch 464 taken 44 times.
✓ Branch 465 taken 111461 times.
✓ Branch 466 taken 111461 times.
✓ Branch 467 taken 20016 times.
✗ Branch 468 not taken.
✗ Branch 469 not taken.
✗ Branch 470 not taken.
✓ Branch 471 taken 1275 times.
✓ Branch 472 taken 4214 times.
✗ Branch 473 not taken.
✗ Branch 474 not taken.
✗ Branch 475 not taken.
✗ Branch 476 not taken.
✗ Branch 477 not taken.
✗ Branch 478 not taken.
✗ Branch 479 not taken.
✗ Branch 480 not taken.
✗ Branch 481 not taken.
✗ Branch 482 not taken.
✗ Branch 483 not taken.
✗ Branch 484 not taken.
✗ Branch 485 not taken.
✗ Branch 486 not taken.
✗ Branch 487 not taken.
✗ Branch 488 not taken.
✗ Branch 489 not taken.
✗ Branch 490 not taken.
✗ Branch 491 not taken.
✗ Branch 492 not taken.
✗ Branch 493 not taken.
✓ Branch 494 taken 1037003 times.
✗ Branch 495 not taken.
✓ Branch 496 taken 3 times.
✗ Branch 497 not taken.
✗ Branch 498 not taken.
✗ Branch 499 not taken.
✓ Branch 500 taken 1041414 times.
✓ Branch 501 taken 969235 times.
✓ Branch 502 taken 972500 times.
✗ Branch 503 not taken.
✓ Branch 504 taken 71 times.
✓ Branch 505 taken 28037 times.
✗ Branch 506 not taken.
✗ Branch 507 not taken.
✗ Branch 508 not taken.
✗ Branch 509 not taken.
✗ Branch 510 not taken.
✗ Branch 511 not taken.
✓ Branch 512 taken 1045600 times.
✗ Branch 513 not taken.
✗ Branch 514 not taken.
✗ Branch 515 not taken.
✗ Branch 516 not taken.
✗ Branch 517 not taken.
✗ Branch 518 not taken.
✗ Branch 519 not taken.
✗ Branch 520 not taken.
✗ Branch 521 not taken.
✓ Branch 522 taken 3 times.
✗ Branch 523 not taken.
✓ Branch 524 taken 4414 times.
✓ Branch 525 taken 1032892 times.
✗ Branch 526 not taken.
✓ Branch 527 taken 788 times.
✗ Branch 528 not taken.
✓ Branch 529 taken 321 times.
✓ Branch 530 taken 94 times.
✗ Branch 531 not taken.
✓ Branch 532 taken 13 times.
✓ Branch 533 taken 77610 times.
✓ Branch 534 taken 1181 times.
✓ Branch 535 taken 4183 times.
✓ Branch 536 taken 7067 times.
✓ Branch 537 taken 7067 times.
✓ Branch 538 taken 2 times.
✓ Branch 539 taken 28758 times.
✗ Branch 540 not taken.
✓ Branch 541 taken 1094 times.
✗ Branch 542 not taken.
✗ Branch 543 not taken.
✓ Branch 544 taken 1019271 times.
✓ Branch 545 taken 10538 times.
✓ Branch 546 taken 10538 times.
✓ Branch 547 taken 8695 times.
✓ Branch 548 taken 4911 times.
✗ Branch 549 not taken.
✗ Branch 550 not taken.
✗ Branch 551 not taken.
✓ Branch 552 taken 545362 times.
✗ Branch 553 not taken.
✗ Branch 554 not taken.
✗ Branch 555 not taken.
✗ Branch 556 not taken.
✗ Branch 557 not taken.
✗ Branch 558 not taken.
✗ Branch 559 not taken.
✗ Branch 560 not taken.
✗ Branch 561 not taken.
✗ Branch 562 not taken.
✗ Branch 563 not taken.
✗ Branch 564 not taken.
✗ Branch 565 not taken.
✗ Branch 566 not taken.
✗ Branch 567 not taken.
✗ Branch 568 not taken.
✗ Branch 569 not taken.
✗ Branch 570 not taken.
✗ Branch 571 not taken.
✗ Branch 572 not taken.
✗ Branch 573 not taken.
✗ Branch 574 not taken.
✗ Branch 575 not taken.
✗ Branch 576 not taken.
✗ Branch 577 not taken.
✓ Branch 578 taken 2 times.
✗ Branch 579 not taken.
✗ Branch 580 not taken.
✗ Branch 581 not taken.
✓ Branch 582 taken 26 times.
✓ Branch 583 taken 88964 times.
✓ Branch 584 taken 88970 times.
✓ Branch 585 taken 88970 times.
✓ Branch 586 taken 2705905 times.
✓ Branch 587 taken 8 times.
✗ Branch 588 not taken.
✗ Branch 589 not taken.
✗ Branch 590 not taken.
✓ Branch 591 taken 64 times.
✗ Branch 592 not taken.
✗ Branch 593 not taken.
✗ Branch 594 not taken.
✗ Branch 595 not taken.
✗ Branch 596 not taken.
✗ Branch 597 not taken.
✗ Branch 598 not taken.
✗ Branch 599 not taken.
✗ Branch 600 not taken.
✗ Branch 601 not taken.
✓ Branch 602 taken 3 times.
✗ Branch 603 not taken.
✓ Branch 604 taken 394 times.
✗ Branch 605 not taken.
✗ Branch 606 not taken.
✗ Branch 607 not taken.
✓ Branch 608 taken 649 times.
✗ Branch 609 not taken.
✗ Branch 610 not taken.
✗ Branch 611 not taken.
✗ Branch 612 not taken.
✗ Branch 613 not taken.
✗ Branch 614 not taken.
✗ Branch 615 not taken.
✗ Branch 616 not taken.
✗ Branch 617 not taken.
✗ Branch 618 not taken.
✗ Branch 619 not taken.
✗ Branch 620 not taken.
✗ Branch 621 not taken.
✗ Branch 622 not taken.
✗ Branch 623 not taken.
✗ Branch 624 not taken.
✗ Branch 625 not taken.
✓ Branch 626 taken 889 times.
✗ Branch 627 not taken.
✓ Branch 628 taken 120341 times.
✓ Branch 629 taken 6481 times.
✗ Branch 630 not taken.
✓ Branch 631 taken 3560 times.
✗ Branch 632 not taken.
✓ Branch 633 taken 81346 times.
✗ Branch 634 not taken.
✓ Branch 635 taken 5356632 times.
✓ Branch 636 taken 5344380 times.
✓ Branch 637 taken 32221 times.
✓ Branch 638 taken 760 times.
✗ Branch 639 not taken.
✗ Branch 640 not taken.
✗ Branch 641 not taken.
✗ Branch 642 not taken.
✗ Branch 643 not taken.
✗ Branch 644 not taken.
✗ Branch 645 not taken.
✗ Branch 646 not taken.
✗ Branch 647 not taken.
✗ Branch 648 not taken.
✗ Branch 649 not taken.
✗ Branch 650 not taken.
✗ Branch 651 not taken.
✗ Branch 652 not taken.
✗ Branch 653 not taken.
✗ Branch 654 not taken.
✗ Branch 655 not taken.
✗ Branch 656 not taken.
✗ Branch 657 not taken.
✗ Branch 658 not taken.
✗ Branch 659 not taken.
✗ Branch 660 not taken.
✗ Branch 661 not taken.
✗ Branch 662 not taken.
✗ Branch 663 not taken.
✗ Branch 664 not taken.
✗ Branch 665 not taken.
✗ Branch 666 not taken.
✗ Branch 667 not taken.
✗ Branch 668 not taken.
✗ Branch 669 not taken.
✗ Branch 670 not taken.
✗ Branch 671 not taken.
✗ Branch 672 not taken.
✗ Branch 673 not taken.
✗ Branch 674 not taken.
✗ Branch 675 not taken.
✗ Branch 676 not taken.
✗ Branch 677 not taken.
✗ Branch 678 not taken.
✗ Branch 679 not taken.
✗ Branch 680 not taken.
✗ Branch 681 not taken.
✗ Branch 682 not taken.
✗ Branch 683 not taken.
✓ Branch 684 taken 128 times.
✓ Branch 685 taken 128 times.
✓ Branch 686 taken 128 times.
✗ Branch 687 not taken.
✗ Branch 688 not taken.
✗ Branch 689 not taken.
✓ Branch 690 taken 5 times.
✓ Branch 691 taken 5 times.
✗ Branch 692 not taken.
✗ Branch 693 not taken.
✗ Branch 694 not taken.
✗ Branch 695 not taken.
✗ Branch 696 not taken.
✗ Branch 697 not taken.
✗ Branch 698 not taken.
✗ Branch 699 not taken.
✗ Branch 700 not taken.
✗ Branch 701 not taken.
✗ Branch 702 not taken.
✗ Branch 703 not taken.
✗ Branch 704 not taken.
✗ Branch 705 not taken.
✗ Branch 706 not taken.
✗ Branch 707 not taken.
✗ Branch 708 not taken.
✗ Branch 709 not taken.
✗ Branch 710 not taken.
✗ Branch 711 not taken.
✗ Branch 712 not taken.
✗ Branch 713 not taken.
✗ Branch 714 not taken.
✗ Branch 715 not taken.
✗ Branch 716 not taken.
✗ Branch 717 not taken.
✗ Branch 718 not taken.
✗ Branch 719 not taken.
✗ Branch 720 not taken.
✗ Branch 721 not taken.
✗ Branch 722 not taken.
✗ Branch 723 not taken.
✗ Branch 724 not taken.
✗ Branch 725 not taken.
✗ Branch 726 not taken.
✗ Branch 727 not taken.
✗ Branch 728 not taken.
✓ Branch 729 taken 14277 times.
✗ Branch 730 not taken.
✓ Branch 731 taken 27297 times.
✓ Branch 732 taken 531 times.
✗ Branch 733 not taken.
✗ Branch 734 not taken.
✗ Branch 735 not taken.
✓ Branch 736 taken 4 times.
✓ Branch 737 taken 900 times.
✓ Branch 738 taken 7214 times.
✓ Branch 739 taken 3579 times.
✗ Branch 740 not taken.
✓ Branch 741 taken 11 times.
✗ Branch 742 not taken.
✗ Branch 743 not taken.
✗ Branch 744 not taken.
✗ Branch 745 not taken.
✗ Branch 746 not taken.
✗ Branch 747 not taken.
✗ Branch 748 not taken.
✗ Branch 749 not taken.
✗ Branch 750 not taken.
✗ Branch 751 not taken.
✗ Branch 752 not taken.
✗ Branch 753 not taken.
✗ Branch 754 not taken.
✓ Branch 755 taken 17 times.
✗ Branch 756 not taken.
✗ Branch 757 not taken.
✗ Branch 758 not taken.
✗ Branch 759 not taken.
✗ Branch 760 not taken.
✗ Branch 761 not taken.
✗ Branch 762 not taken.
✗ Branch 763 not taken.
✗ Branch 764 not taken.
✗ Branch 765 not taken.
✗ Branch 766 not taken.
✗ Branch 767 not taken.
✗ Branch 768 not taken.
✗ Branch 769 not taken.
✗ Branch 770 not taken.
✗ Branch 771 not taken.
✗ Branch 772 not taken.
✗ Branch 773 not taken.
✗ Branch 774 not taken.
✗ Branch 775 not taken.
✗ Branch 776 not taken.
✗ Branch 777 not taken.
✗ Branch 778 not taken.
✗ Branch 779 not taken.
✗ Branch 780 not taken.
✗ Branch 781 not taken.
✗ Branch 782 not taken.
✗ Branch 783 not taken.
✗ Branch 784 not taken.
✗ Branch 785 not taken.
✗ Branch 786 not taken.
✗ Branch 787 not taken.
✗ Branch 788 not taken.
✗ Branch 789 not taken.
✗ Branch 790 not taken.
✗ Branch 791 not taken.
✗ Branch 792 not taken.
✗ Branch 793 not taken.
✗ Branch 794 not taken.
✗ Branch 795 not taken.
✗ Branch 796 not taken.
✗ Branch 797 not taken.
✗ Branch 798 not taken.
✗ Branch 799 not taken.
✗ Branch 800 not taken.
✗ Branch 801 not taken.
✗ Branch 802 not taken.
✗ Branch 803 not taken.
✗ Branch 804 not taken.
✗ Branch 805 not taken.
✗ Branch 806 not taken.
✗ Branch 807 not taken.
✗ Branch 808 not taken.
✗ Branch 809 not taken.
✗ Branch 810 not taken.
✗ Branch 811 not taken.
✗ Branch 812 not taken.
✗ Branch 813 not taken.
✗ Branch 814 not taken.
✗ Branch 815 not taken.
✗ Branch 816 not taken.
✗ Branch 817 not taken.
✗ Branch 818 not taken.
✗ Branch 819 not taken.
✗ Branch 820 not taken.
✗ Branch 821 not taken.
✗ Branch 822 not taken.
✗ Branch 823 not taken.
✗ Branch 824 not taken.
✗ Branch 825 not taken.
✗ Branch 826 not taken.
✗ Branch 827 not taken.
✗ Branch 828 not taken.
✗ Branch 829 not taken.
✗ Branch 830 not taken.
✗ Branch 831 not taken.
✗ Branch 832 not taken.
✗ Branch 833 not taken.
✗ Branch 834 not taken.
✗ Branch 835 not taken.
✗ Branch 836 not taken.
✗ Branch 837 not taken.
✗ Branch 838 not taken.
✗ Branch 839 not taken.
✗ Branch 840 not taken.
✗ Branch 841 not taken.
✗ Branch 842 not taken.
✗ Branch 843 not taken.
✗ Branch 844 not taken.
✗ Branch 845 not taken.
✗ Branch 846 not taken.
✗ Branch 847 not taken.
✗ Branch 848 not taken.
✗ Branch 849 not taken.
✗ Branch 850 not taken.
✗ Branch 851 not taken.
✗ Branch 852 not taken.
✗ Branch 853 not taken.
✗ Branch 854 not taken.
✗ Branch 855 not taken.
✓ Branch 856 taken 80782 times.
✓ Branch 857 taken 2497 times.
✓ Branch 858 taken 56174 times.
✗ Branch 859 not taken.
✗ Branch 860 not taken.
✗ Branch 861 not taken.
✗ Branch 862 not taken.
✗ Branch 863 not taken.
✗ Branch 864 not taken.
✗ Branch 865 not taken.
✗ Branch 866 not taken.
✗ Branch 867 not taken.
✗ Branch 868 not taken.
✗ Branch 869 not taken.
✗ Branch 870 not taken.
✗ Branch 871 not taken.
✗ Branch 872 not taken.
✗ Branch 873 not taken.
✗ Branch 874 not taken.
✗ Branch 875 not taken.
✗ Branch 876 not taken.
✗ Branch 877 not taken.
✗ Branch 878 not taken.
✗ Branch 879 not taken.
✗ Branch 880 not taken.
✗ Branch 881 not taken.
✗ Branch 882 not taken.
✗ Branch 883 not taken.
✗ Branch 884 not taken.
✗ Branch 885 not taken.
✗ Branch 886 not taken.
✗ Branch 887 not taken.
✗ Branch 888 not taken.
✗ Branch 889 not taken.
✗ Branch 890 not taken.
✗ Branch 891 not taken.
✗ Branch 892 not taken.
✗ Branch 893 not taken.
✗ Branch 894 not taken.
✗ Branch 895 not taken.
✗ Branch 896 not taken.
✗ Branch 897 not taken.
✗ Branch 898 not taken.
✗ Branch 899 not taken.
✗ Branch 900 not taken.
✓ Branch 901 taken 3225 times.
✗ Branch 902 not taken.
✗ Branch 903 not taken.
✗ Branch 904 not taken.
✗ Branch 905 not taken.
✗ Branch 906 not taken.
✗ Branch 907 not taken.
✗ Branch 908 not taken.
✗ Branch 909 not taken.
✗ Branch 910 not taken.
✗ Branch 911 not taken.
✗ Branch 912 not taken.
✗ Branch 913 not taken.
✗ Branch 914 not taken.
✗ Branch 915 not taken.
✗ Branch 916 not taken.
✗ Branch 917 not taken.
✗ Branch 918 not taken.
✗ Branch 919 not taken.
✗ Branch 920 not taken.
✗ Branch 921 not taken.
✗ Branch 922 not taken.
✗ Branch 923 not taken.
✗ Branch 924 not taken.
✗ Branch 925 not taken.
✗ Branch 926 not taken.
✗ Branch 927 not taken.
✗ Branch 928 not taken.
✗ Branch 929 not taken.
✗ Branch 930 not taken.
✗ Branch 931 not taken.
✗ Branch 932 not taken.
✗ Branch 933 not taken.
✗ Branch 934 not taken.
✗ Branch 935 not taken.
✗ Branch 936 not taken.
✗ Branch 937 not taken.
✗ Branch 938 not taken.
✗ Branch 939 not taken.
✗ Branch 940 not taken.
✗ Branch 941 not taken.
✗ Branch 942 not taken.
✗ Branch 943 not taken.
✗ Branch 944 not taken.
✗ Branch 945 not taken.
✗ Branch 946 not taken.
✗ Branch 947 not taken.
✗ Branch 948 not taken.
✗ Branch 949 not taken.
✗ Branch 950 not taken.
✗ Branch 951 not taken.
✗ Branch 952 not taken.
✗ Branch 953 not taken.
✗ Branch 954 not taken.
✗ Branch 955 not taken.
✗ Branch 956 not taken.
✗ Branch 957 not taken.
✗ Branch 958 not taken.
✗ Branch 959 not taken.
✗ Branch 960 not taken.
✗ Branch 961 not taken.
✗ Branch 962 not taken.
✗ Branch 963 not taken.
✗ Branch 964 not taken.
✗ Branch 965 not taken.
✗ Branch 966 not taken.
✗ Branch 967 not taken.
✗ Branch 968 not taken.
✗ Branch 969 not taken.
✗ Branch 970 not taken.
✗ Branch 971 not taken.
✗ Branch 972 not taken.
✗ Branch 973 not taken.
✗ Branch 974 not taken.
✗ Branch 975 not taken.
✗ Branch 976 not taken.
✗ Branch 977 not taken.
✗ Branch 978 not taken.
✗ Branch 979 not taken.
✗ Branch 980 not taken.
✗ Branch 981 not taken.
✗ Branch 982 not taken.
✗ Branch 983 not taken.
✗ Branch 984 not taken.
✗ Branch 985 not taken.
✗ Branch 986 not taken.
✗ Branch 987 not taken.
✗ Branch 988 not taken.
✗ Branch 989 not taken.
✗ Branch 990 not taken.
✗ Branch 991 not taken.
✗ Branch 992 not taken.
✗ Branch 993 not taken.
✗ Branch 994 not taken.
✗ Branch 995 not taken.
✗ Branch 996 not taken.
✗ Branch 997 not taken.
✗ Branch 998 not taken.
✗ Branch 999 not taken.
✗ Branch 1000 not taken.
✗ Branch 1001 not taken.
✗ Branch 1002 not taken.
✗ Branch 1003 not taken.
✗ Branch 1004 not taken.
✗ Branch 1005 not taken.
✗ Branch 1006 not taken.
✗ Branch 1007 not taken.
✗ Branch 1008 not taken.
✗ Branch 1009 not taken.
✗ Branch 1010 not taken.
✗ Branch 1011 not taken.
✗ Branch 1012 not taken.
✗ Branch 1013 not taken.
✗ Branch 1014 not taken.
✗ Branch 1015 not taken.
✗ Branch 1016 not taken.
✗ Branch 1017 not taken.
✗ Branch 1018 not taken.
✗ Branch 1019 not taken.
✗ Branch 1020 not taken.
✗ Branch 1021 not taken.
✗ Branch 1022 not taken.
✗ Branch 1023 not taken.
✗ Branch 1024 not taken.
✗ Branch 1025 not taken.
✗ Branch 1026 not taken.
✗ Branch 1027 not taken.
✗ Branch 1028 not taken.
✗ Branch 1029 not taken.
✗ Branch 1030 not taken.
✗ Branch 1031 not taken.
✗ Branch 1032 not taken.
✗ Branch 1033 not taken.
✗ Branch 1034 not taken.
✗ Branch 1035 not taken.
✗ Branch 1036 not taken.
✗ Branch 1037 not taken.
✗ Branch 1038 not taken.
✗ Branch 1039 not taken.
✗ Branch 1040 not taken.
✗ Branch 1041 not taken.
✗ Branch 1042 not taken.
✗ Branch 1043 not taken.
✗ Branch 1044 not taken.
✗ Branch 1045 not taken.
✗ Branch 1046 not taken.
✗ Branch 1047 not taken.
✗ Branch 1048 not taken.
✗ Branch 1049 not taken.
✗ Branch 1050 not taken.
✗ Branch 1051 not taken.
✗ Branch 1052 not taken.
✗ Branch 1053 not taken.
✗ Branch 1054 not taken.
✗ Branch 1055 not taken.
✗ Branch 1056 not taken.
✗ Branch 1057 not taken.
✗ Branch 1058 not taken.
✗ Branch 1059 not taken.
✗ Branch 1060 not taken.
✗ Branch 1061 not taken.
✗ Branch 1062 not taken.
✗ Branch 1063 not taken.
✗ Branch 1064 not taken.
✗ Branch 1065 not taken.
✗ Branch 1066 not taken.
✗ Branch 1067 not taken.
✗ Branch 1068 not taken.
✗ Branch 1069 not taken.
✗ Branch 1070 not taken.
✗ Branch 1071 not taken.
✗ Branch 1072 not taken.
✗ Branch 1073 not taken.
✗ Branch 1074 not taken.
✗ Branch 1075 not taken.
✗ Branch 1076 not taken.
✗ Branch 1077 not taken.
✗ Branch 1078 not taken.
✗ Branch 1079 not taken.
✗ Branch 1080 not taken.
✗ Branch 1081 not taken.
✗ Branch 1082 not taken.
✗ Branch 1083 not taken.
✗ Branch 1084 not taken.
✗ Branch 1085 not taken.
✗ Branch 1086 not taken.
✗ Branch 1087 not taken.
✗ Branch 1088 not taken.
✗ Branch 1089 not taken.
✗ Branch 1090 not taken.
✗ Branch 1091 not taken.
✗ Branch 1092 not taken.
✗ Branch 1093 not taken.
✗ Branch 1094 not taken.
✗ Branch 1095 not taken.
✗ Branch 1096 not taken.
✗ Branch 1097 not taken.
✗ Branch 1098 not taken.
✗ Branch 1099 not taken.
✗ Branch 1100 not taken.
✗ Branch 1101 not taken.
✗ Branch 1102 not taken.
✗ Branch 1103 not taken.
✗ Branch 1104 not taken.
✗ Branch 1105 not taken.
✗ Branch 1106 not taken.
✗ Branch 1107 not taken.
✗ Branch 1108 not taken.
✗ Branch 1109 not taken.
✗ Branch 1110 not taken.
✗ Branch 1111 not taken.
✗ Branch 1112 not taken.
✗ Branch 1113 not taken.
✗ Branch 1114 not taken.
✗ Branch 1115 not taken.
✗ Branch 1116 not taken.
✗ Branch 1117 not taken.
✗ Branch 1118 not taken.
✗ Branch 1119 not taken.
✗ Branch 1120 not taken.
✗ Branch 1121 not taken.
✗ Branch 1122 not taken.
✗ Branch 1123 not taken.
✗ Branch 1124 not taken.
✗ Branch 1125 not taken.
✓ Branch 1126 taken 503793138 times.
✓ Branch 1127 taken 409929 times.
✓ Branch 1128 taken 2162208 times.
✓ Branch 1129 taken 10116373 times.
✓ Branch 1130 taken 23554631 times.
✓ Branch 1131 taken 78110851 times.
✓ Branch 1132 taken 18561592 times.
✗ Branch 1133 not taken.
✓ Branch 1134 taken 116558 times.
✓ Branch 1135 taken 64 times.
✓ Branch 1136 taken 265857 times.
✗ Branch 1137 not taken.
✓ Branch 1138 taken 805094 times.
✗ Branch 1139 not taken.
✗ Branch 1140 not taken.
✗ Branch 1141 not taken.
✗ Branch 1142 not taken.
✗ Branch 1143 not taken.
✗ Branch 1144 not taken.
✓ Branch 1145 taken 142 times.
✗ Branch 1146 not taken.
✗ Branch 1147 not taken.
✗ Branch 1148 not taken.
✗ Branch 1149 not taken.
✗ Branch 1150 not taken.
✗ Branch 1151 not taken.
✗ Branch 1152 not taken.
✗ Branch 1153 not taken.
✗ Branch 1154 not taken.
✗ Branch 1155 not taken.
✓ Branch 1156 taken 284 times.
✗ Branch 1157 not taken.
✗ Branch 1158 not taken.
✗ Branch 1159 not taken.
✓ Branch 1160 taken 303330 times.
✗ Branch 1161 not taken.
✗ Branch 1162 not taken.
✗ Branch 1163 not taken.
✗ Branch 1164 not taken.
✗ Branch 1165 not taken.
✗ Branch 1166 not taken.
✗ Branch 1167 not taken.
✓ Branch 1168 taken 58 times.
✗ Branch 1169 not taken.
✗ Branch 1170 not taken.
✓ Branch 1171 taken 74 times.
✗ Branch 1172 not taken.
✗ Branch 1173 not taken.
✗ Branch 1174 not taken.
✗ Branch 1175 not taken.
✗ Branch 1176 not taken.
✗ Branch 1177 not taken.
✗ Branch 1178 not taken.
✗ Branch 1179 not taken.
✗ Branch 1180 not taken.
✗ Branch 1181 not taken.
✗ Branch 1182 not taken.
✗ Branch 1183 not taken.
✗ Branch 1184 not taken.
✗ Branch 1185 not taken.
✗ Branch 1186 not taken.
✗ Branch 1187 not taken.
✗ Branch 1188 not taken.
✗ Branch 1189 not taken.
✗ Branch 1190 not taken.
✗ Branch 1191 not taken.
✗ Branch 1192 not taken.
✗ Branch 1193 not taken.
1401178322 switch(arg)
13478 {
13479 //debug ri->d[]
13480 case DEBUGD:
13481 {
13482 int32_t a = vbound((ri->d[rINDEX] / 10000), 0, 255);
13483 ri->d[a] = value/10000;
13484 break;
13485 }
13486
13487 ///----------------------------------------------------------------------------------------------------//
13488 //FFC Variables
13489 case DATA:
13490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2270014 times.
2270014 if(BC::checkFFC(ri->ffcref, "ffc->Data") == SH::_NoError)
13491 {
13492 2270014 tmpscr->ffcs[ri->ffcref].setData(vbound(value/10000,0,MAXCOMBOS-1));
13493 2270014 }
13494 2270014 break;
13495
13496 case FFSCRIPT:
13497
1/2
✓ Branch 0 taken 9724 times.
✗ Branch 1 not taken.
9724 if(BC::checkFFC(ri->ffcref, "ffc->Script") == SH::_NoError)
13498 {
13499 9724 tmpscr->ffcs[ri->ffcref].script = vbound(value/10000, 0, NUMSCRIPTFFC-1);
13500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9724 times.
9724 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
13501 {
13502
2/2
✓ Branch 0 taken 19448 times.
✓ Branch 1 taken 9724 times.
29172 for(int32_t i=0; i<2; i++)
13503 19448 tmpscr->ffcs[ri->ffcref].inita[i] = 0;
13504
13505
2/2
✓ Branch 0 taken 77792 times.
✓ Branch 1 taken 9724 times.
87516 for(int32_t i=0; i<8; i++)
13506 77792 tmpscr->ffcs[ri->ffcref].initd[i] = 0;
13507 9724 }
13508
2/2
✓ Branch 0 taken 155584 times.
✓ Branch 1 taken 9724 times.
165308 for(int32_t i=0; i<16; i++)
13509 155584 ffmisc[ri->ffcref][i] = 0;
13510
13511 9724 auto& data = get_script_engine_data(ScriptType::FFC, ri->ffcref);
13512 9724 data.ref.Clear();
13513 9724 data.initialized = false;
13514 9724 FFScript::deallocateAllArrays(ScriptType::FFC, ri->ffcref);
13515 9724 }
13516 9724 break;
13517
13518
13519 case FCSET:
13520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1041229 times.
1041229 if(BC::checkFFC(ri->ffcref, "ffc->CSet") == SH::_NoError)
13521 1041229 tmpscr->ffcs[ri->ffcref].cset = (value/10000)&15;
13522 1041229 break;
13523
13524 case DELAY:
13525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2881 times.
2881 if(BC::checkFFC(ri->ffcref, "ffc->Delay") == SH::_NoError)
13526 2881 tmpscr->ffcs[ri->ffcref].delay = value/10000;
13527 2881 break;
13528
13529 case FX:
13530
1/2
✓ Branch 0 taken 1213780 times.
✗ Branch 1 not taken.
1213780 if(BC::checkFFC(ri->ffcref, "ffc->X") == SH::_NoError)
13531 1213780 tmpscr->ffcs[ri->ffcref].x = zslongToFix(value);
13532 1213780 break;
13533
13534 case FY:
13535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1215785 times.
1215785 if(BC::checkFFC(ri->ffcref, "ffc->Y") == SH::_NoError)
13536 1215785 tmpscr->ffcs[ri->ffcref].y=zslongToFix(value);
13537 1215785 break;
13538
13539 case XD:
13540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9444 times.
9444 if(BC::checkFFC(ri->ffcref, "ffc->Vx") == SH::_NoError)
13541 9444 tmpscr->ffcs[ri->ffcref].vx=zslongToFix(value);
13542 9444 break;
13543
13544 case YD:
13545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9428 times.
9428 if(BC::checkFFC(ri->ffcref, "ffc->Vy") == SH::_NoError)
13546 9428 tmpscr->ffcs[ri->ffcref].vy=zslongToFix(value);
13547 9428 break;
13548
13549 case FFCID:
13550 break;
13551
13552 case XD2:
13553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9172 times.
9172 if(BC::checkFFC(ri->ffcref, "ffc->Ax") == SH::_NoError)
13554 9172 tmpscr->ffcs[ri->ffcref].ax=zslongToFix(value);
13555 9172 break;
13556
13557 case YD2:
13558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9172 times.
9172 if(BC::checkFFC(ri->ffcref, "ffc->Ay") == SH::_NoError)
13559 9172 tmpscr->ffcs[ri->ffcref].ay=zslongToFix(value);
13560 9172 break;
13561
13562 case FFFLAGSD:
13563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 229038 times.
229038 if(BC::checkFFC(ri->ffcref, "ffc->Flags[]") == SH::_NoError)
13564 {
13565 229038 auto flag = 1<<((ri->d[rINDEX])/10000);
13566 229038 ffcdata& ff = tmpscr->ffcs[ri->ffcref];
13567
2/2
✓ Branch 0 taken 31750 times.
✓ Branch 1 taken 197288 times.
229038 SETFLAG(ff.flags, flag, value);
13568
4/4
✓ Branch 0 taken 225801 times.
✓ Branch 1 taken 3237 times.
✓ Branch 2 taken 3407 times.
✓ Branch 3 taken 222394 times.
229038 if (flag == ffSOLID || flag == ffCHANGER)
13569 6644 ff.updateSolid();
13570 229038 }
13571 229038 break;
13572
13573 case FFCWIDTH:
13574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3248 times.
3248 if(BC::checkFFC(ri->ffcref, "ffc->EffectWidth") == SH::_NoError)
13575 3248 tmpscr->ffcs[ri->ffcref].hit_width = (value/10000);
13576 3248 break;
13577
13578 case FFCHEIGHT:
13579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3250 times.
3250 if(BC::checkFFC(ri->ffcref, "ffc->EffectHeight") == SH::_NoError)
13580 3250 tmpscr->ffcs[ri->ffcref].hit_height = (value/10000);
13581 3250 break;
13582
13583 case FFTWIDTH:
13584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9502 times.
9502 if(BC::checkFFC(ri->ffcref, "ffc->TileWidth") == SH::_NoError)
13585 9502 tmpscr->ffcs[ri->ffcref].txsz = vbound(value/10000, 1, 4);
13586 9502 break;
13587
13588 case FFTHEIGHT:
13589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9512 times.
9512 if(BC::checkFFC(ri->ffcref, "ffc->TileHeight") == SH::_NoError)
13590 9512 tmpscr->ffcs[ri->ffcref].tysz = vbound(value/10000, 1, 4);
13591 9512 break;
13592
13593 case FFLINK:
13594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 616 times.
616 if(BC::checkFFC(ri->ffcref, "ffc->Link") == SH::_NoError)
13595 616 (tmpscr->ffcs[ri->ffcref].link)=vbound(value/10000, 0, MAXFFCS); // Allow "ffc->Link = 0" to unlink ffc.
13596 //0 is none, setting this before made it impssible to clear it. -Z
13597 616 break;
13598
13599 case FFMISCD:
13600 {
13601 900 int32_t a = vbound(ri->d[rINDEX]/10000,0,15);
13602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 900 times.
900 if(BC::checkFFC(ri->ffcref, "ffc->Misc[]")== SH::_NoError)
13603 900 ffmisc[ri->ffcref][a]=value;
13604 900 break;
13605 }
13606
13607 case FFINITDD:
13608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17706 times.
17706 if(BC::checkFFC(ri->ffcref, "ffc->InitD[]") == SH::_NoError)
13609 17706 (tmpscr->ffcs[ri->ffcref].initd[vbound(ri->d[rINDEX]/10000,0,7)])=value;
13610 17706 break;
13611
13612 case FFCLASTCHANGERX:
13613 if(BC::checkFFC(ri->ffcref, "ffc->LastChangerX") == SH::_NoError)
13614 ffposx[ri->ffcref]=vbound(zslongToFix(value).getInt(),-32768, 32767);
13615 break;
13616
13617 case FFCLASTCHANGERY:
13618 if(BC::checkFFC(ri->ffcref, "ffc->LastChangerY") == SH::_NoError)
13619 ffposy[ri->ffcref]=vbound(zslongToFix(value).getInt(),-32768, 32767);
13620 break;
13621
13622
13623
13624 ///----------------------------------------------------------------------------------------------------//
13625 //Hero's Variables
13626 case LINKX:
13627 {
13628
2/2
✓ Branch 0 taken 1210 times.
✓ Branch 1 taken 443391 times.
444601 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
13629 {
13630 1210 Hero.setXfix(zslongToFix(value));
13631 1210 }
13632 else
13633 {
13634 443391 Hero.setX(value/10000);
13635 }
13636 }
13637 444601 break;
13638
13639 case LINKCSET:
13640 {
13641 Hero.cs = value/10000;
13642 break;
13643 }
13644 case LINKY:
13645 {
13646
2/2
✓ Branch 0 taken 1071 times.
✓ Branch 1 taken 457869 times.
458940 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
13647 {
13648 1071 Hero.setYfix(zslongToFix(value));
13649 1071 }
13650 else
13651 {
13652 457869 Hero.setY(value/10000);
13653 }
13654 }
13655 458940 break;
13656
13657 case LINKZ:
13658 {
13659
2/2
✓ Branch 0 taken 2767 times.
✓ Branch 1 taken 2 times.
2769 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
13660 {
13661 2767 Hero.setZfix(zslongToFix(value));
13662 2767 }
13663 else
13664 {
13665 2 Hero.setZ(value/10000);
13666 }
13667 }
13668 2769 break;
13669
13670 case LINKJUMP:
13671 64379 Hero.setFall(zslongToFix(value) * -100);
13672 64379 break;
13673
13674 case HEROFAKEJUMP:
13675 Hero.setFakeFall(zslongToFix(value) * -100);
13676 break;
13677
13678 case LINKDIR:
13679 {
13680 //Hero->setDir() calls reset_hookshot(), which removes the sword sprite.. O_o
13681
3/4
✓ Branch 0 taken 93219 times.
✓ Branch 1 taken 475 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93219 times.
93694 if(Hero.getAction() == attacking || Hero.getAction() == sideswimattacking) Hero.dir = (value/10000);
13682 93219 else Hero.setDir(value/10000);
13683
13684 93694 break;
13685 }
13686
13687 case LINKHITDIR:
13688 Hero.setHitDir(value / 10000);
13689 break;
13690
13691 case LINKGRAVITY:
13692 if(value)
13693 Hero.moveflags |= FLAG_OBEYS_GRAV;
13694 else
13695 Hero.moveflags &= ~FLAG_OBEYS_GRAV;
13696 break;
13697
13698 case HERONOSTEPFORWARD:
13699 FFCore.nostepforward = ( (value) ? 1 : 0 );
13700 break;
13701
13702 case LINKHP:
13703
6/6
✓ Branch 0 taken 174180 times.
✓ Branch 1 taken 96374 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 270528 times.
✓ Branch 4 taken 174154 times.
✓ Branch 5 taken 96374 times.
270554 game->set_life(zc_max(0, zc_min(value/10000,game->get_maxlife())));
13704 270554 break;
13705
13706 case LINKMP:
13707
6/6
✓ Branch 0 taken 4662 times.
✓ Branch 1 taken 5754 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 10415 times.
✓ Branch 4 taken 4661 times.
✓ Branch 5 taken 5754 times.
10416 game->set_magic(zc_max(0, zc_min(value/10000,game->get_maxmagic())));
13708 10416 break;
13709
13710 case LINKMAXHP:
13711 56 game->set_maxlife(value/10000);
13712 56 break;
13713
13714 case LINKMAXMP:
13715 game->set_maxmagic(value/10000);
13716 break;
13717
13718 case LINKACTION:
13719 {
13720 388 int32_t act = value / 10000;
13721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 388 times.
388 switch(act)
13722 {
13723 case hookshotout:
13724 case stunned:
13725 case ispushing:
13726 FFCore.setHeroAction(act);
13727 break;
13728 default:
13729 388 Hero.setAction((actiontype)(act));
13730 388 }
13731 //Protect from writing illegal actions to Hero's raw variable.
13732 //in the future, we can move all scripted actions that are not possible
13733 //to set in ZC into this mechanic. -Z
13734 388 break;
13735 }
13736
13737 case HEROHEALTHBEEP:
13738 {
13739 int32_t beep = vbound((value/10000),-4, 255);
13740 //-2 suspends system control of stopping the sound
13741 //-3 suspends system control of stopping the sound AND suspends
13742 // system control over starting or playing it.
13743 heart_beep_timer = beep;
13744 if ( heart_beep_timer > -1 )
13745 {
13746 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
13747 }
13748 else
13749 {
13750 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
13751 }
13752 break;
13753 }
13754
13755 case LINKHELD:
13756 Hero.setHeldItem(vbound(value/10000,0,MAXITEMS-1));
13757 break;
13758
13759 case HEROSTEPS:
13760 {
13761 lsteps[vbound(ri->d[rINDEX]/10000,0,7)] = value/10000;
13762 break;
13763 }
13764
13765 case HEROSTEPRATE:
13766 if(!get_qr(qr_NEW_HERO_MOVEMENT))
13767 {
13768 Z_scripterrlog("To use '%s', you must %s the quest rule '%s'.", "Hero->Step", "enable", "New Player Movement");
13769 }
13770 Hero.setStepRate(zc_max(value/10000,0));
13771 if(!get_qr(qr_SCRIPT_WRITING_HEROSTEP_DOESNT_CARRY_OVER))
13772 zinit.heroStep = Hero.getStepRate();
13773 break;
13774
13775 case LINKITEMD:
13776 {
13777 5906 int32_t itemID=vbound(ri->d[rINDEX]/10000,0,MAXITEMS-1);
13778
13779 // If the Cane of Byrna is being removed, cancel its effect.
13780
3/4
✓ Branch 0 taken 3219 times.
✓ Branch 1 taken 2687 times.
✓ Branch 2 taken 3219 times.
✗ Branch 3 not taken.
5906 if(value==0 && itemID==current_item_id(itype_cbyrna))
13781 stopCaneOfByrna();
13782
13783 5906 auto& data = get_script_engine_data(ScriptType::Item, itemID);
13784
13785 //Stop current script if set false.
13786
4/4
✓ Branch 0 taken 3219 times.
✓ Branch 1 taken 2687 times.
✓ Branch 2 taken 3203 times.
✓ Branch 3 taken 16 times.
5906 if ( !value && data.doscript )
13787 {
13788 16 data.doscript = 4; //Val of 4 means 'clear stack and quit'
13789 //itemScriptData[itemID].Clear(); //Don't clear here, causes crash if is current item!
13790 16 }
13791
4/4
✓ Branch 0 taken 2687 times.
✓ Branch 1 taken 3203 times.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 2645 times.
5890 else if ( value && !data.doscript )
13792 {
13793 //Clear the item refInfo and stack for use.
13794 2645 data.ref.Clear();
13795
1/2
✓ Branch 0 taken 2645 times.
✗ Branch 1 not taken.
2645 if ( (itemsbuf[itemID].flags&ITEM_PASSIVESCRIPT) ) data.doscript = 1;
13796 2645 }
13797
3/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 3203 times.
✓ Branch 2 taken 42 times.
✗ Branch 3 not taken.
3245 else if ( value && data.doscript == 4 )
13798 {
13799 // Arbitrary event number 49326: Writing the item false, then true, in the same frame. -Z
13800 if ( (itemsbuf[itemID].flags&ITEM_PASSIVESCRIPT) ) data.doscript = 1;
13801 }
13802
13803 5906 bool settrue = ( value != 0 );
13804
13805 //Sanity check to prevent setting the item if the value would be the same. -Z
13806
2/2
✓ Branch 0 taken 3834 times.
✓ Branch 1 taken 2072 times.
5906 if ( game->item[itemID] != settrue )
13807 {
13808 2072 game->set_item(itemID,(value != 0));
13809 2072 }
13810
13811
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5906 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5906 if((get_qr(qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
13812 {
13813 5906 ringcolor(false);
13814 //refreshpal=true;
13815 5906 }
13816
2/2
✓ Branch 0 taken 2687 times.
✓ Branch 1 taken 3219 times.
5906 if ( !value ) //setting the item false clears the state of forced ->Equipment writes.
13817 {
13818
1/2
✓ Branch 0 taken 3219 times.
✗ Branch 1 not taken.
3219 if ( game->forced_bwpn == itemID )
13819 {
13820 game->forced_bwpn = -1;
13821 } //not else if! -Z
13822
2/2
✓ Branch 0 taken 3218 times.
✓ Branch 1 taken 1 times.
3219 if ( game->forced_awpn == itemID )
13823 {
13824 1 game->forced_awpn = -1;
13825 1 }
13826
2/2
✓ Branch 0 taken 3216 times.
✓ Branch 1 taken 3 times.
3219 if ( game->forced_xwpn == itemID )
13827 {
13828 3 game->forced_xwpn = -1;
13829 3 }
13830
2/2
✓ Branch 0 taken 3216 times.
✓ Branch 1 taken 3 times.
3219 if ( game->forced_ywpn == itemID )
13831 {
13832 3 game->forced_ywpn = -1;
13833 3 }
13834 3219 }
13835 }
13836 5906 break;
13837
13838 case LINKEQUIP:
13839 {
13840 if ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) < 33 )
13841 {
13842 break;
13843 }
13844 //int32_t seta = (value/10000) >> 8; int32_t setb = value/10000) & 0xFF;
13845 int32_t setb = ((value/10000)&0xFF00)>>8, seta = (value/10000)&0xFF;
13846 seta = vbound(seta,-1,255);
13847 setb = vbound(setb,-1,255);
13848 //zprint("A is: %d\n", seta);
13849 //zprint("A is: %d\n", setb);
13850
13851 Awpn = seta;
13852 game->awpn = seta;
13853 game->forced_awpn = seta;
13854 game->items_off[seta] = 0;
13855 directItemA = seta;
13856
13857 Bwpn = setb;
13858 game->bwpn = setb;
13859 game->forced_bwpn = setb;
13860 game->items_off[setb] = 0;
13861 directItemB = seta;
13862 break;
13863 }
13864
13865
13866 case SETITEMSLOT:
13867 {
13868 //ri->d[rINDEX2] = 1st arg
13869 //ri->d[rINDEX] = 2nd arg
13870 //value = third arg
13871 //int32_t item, int32_t slot, int32_t force
13872 int32_t itm = ri->d[rINDEX]/10000;
13873 itm = vbound(itm, -1, 255);
13874
13875 int32_t slot = ri->d[rINDEX2]/10000;
13876 int32_t force = ri->d[rEXP1]/10000;
13877
13878 zprint("SetItemSlot rid->[0] is (%i), trying to use for '%s'\n", itm, "itm");
13879 zprint("SetItemSlot rid->[1] is (%i), trying to use for '%s'\n", slot, "slot");
13880 zprint("SetItemSlot rid->[2] is (%i), trying to use for '%s'\n", force, "force");
13881
13882 //If we add more item buttons, slot should be an int32_t
13883 //and force shuld be an int32_t
13884
13885 /*
13886 For zScript,
13887 const int32_t ITM_REQUIRE_NONE = 0
13888 const int32_t ITM_REQUIRE_INVENTORY = 1
13889 const int32_t ITM_REQUIRE_A_SLOT_RULE = 2
13890 //Combine as flags
13891 */
13892 if ( force == 0 )
13893 {
13894 switch(slot)
13895 {
13896 case 0: //b
13897 Bwpn = itm;
13898 game->items_off[itm] = 0;
13899 game->bwpn = itm;
13900 game->forced_bwpn = itm;
13901 break;
13902
13903 case 1: //a
13904 Awpn = itm;
13905 game->items_off[itm] = 0;
13906 game->awpn = itm;
13907 game->forced_awpn = itm;
13908 break;
13909
13910 case 2: //x
13911 Xwpn = itm;
13912 game->items_off[itm] = 0;
13913 game->xwpn = itm;
13914 game->forced_xwpn = itm;
13915 break;
13916
13917 case 3: //y
13918 Ywpn = itm;
13919 game->items_off[itm] = 0;
13920 game->ywpn = itm;
13921 game->forced_ywpn = itm;
13922 break;
13923 }
13924 }
13925 else if ( force == 1 )
13926 {
13927 if (game->item[itm])
13928 {
13929 switch(slot)
13930 {
13931 case 0: //b
13932 Bwpn = itm;
13933 game->items_off[itm] = 0;
13934 game->bwpn = itm;
13935 game->forced_bwpn = itm;
13936 break;
13937
13938 case 1: //a
13939 Awpn = itm;
13940 game->items_off[itm] = 0;
13941 game->awpn = itm;
13942 game->forced_awpn = itm;
13943 break;
13944
13945 case 2: //x
13946 Xwpn = itm;
13947 game->items_off[itm] = 0;
13948 game->xwpn = itm;
13949 game->forced_xwpn = itm;
13950 break;
13951
13952 case 3: //y
13953 Ywpn = itm;
13954 game->items_off[itm] = 0;
13955 game->ywpn = itm;
13956 game->forced_ywpn = itm;
13957 break;
13958 }
13959 }
13960 }
13961 else if ( force == 2 )
13962 {
13963 switch(slot)
13964 {
13965 case 0: //b
13966 Bwpn = itm;
13967 game->items_off[itm] = 0;
13968 game->bwpn = itm;
13969 game->forced_bwpn = itm;
13970 break;
13971
13972 case 1: //a
13973 {
13974 if (get_qr(qr_SELECTAWPN))
13975 {
13976 Awpn = itm;
13977 game->items_off[itm] = 0;
13978 game->awpn = itm;
13979 game->forced_awpn = itm;
13980 }
13981 break;
13982 }
13983
13984 case 2: //x
13985 Xwpn = itm;
13986 game->items_off[itm] = 0;
13987 game->xwpn = itm;
13988 game->forced_xwpn = itm;
13989 break;
13990
13991 case 3: //y
13992 Ywpn = itm;
13993 game->items_off[itm] = 0;
13994 game->ywpn = itm;
13995 game->forced_ywpn = itm;
13996 break;
13997 }
13998 }
13999 else if ( force == 3 ) //Flag ITM_REQUIRE_INVENTORY + ITM_REQUIRE_SLOT_A_RULE
14000 {
14001 if ( game->item[itm] )
14002 {
14003 switch(slot)
14004 {
14005 case 0: //b
14006 Bwpn = itm;
14007 game->items_off[itm] = 0;
14008 game->bwpn = itm;
14009 game->forced_bwpn = itm;
14010 break;
14011
14012 case 1: //a
14013 {
14014 if (get_qr(qr_SELECTAWPN))
14015 {
14016 Awpn = itm;
14017 game->items_off[itm] = 0;
14018 game->awpn = itm;
14019 game->forced_awpn = itm;
14020 }
14021 break;
14022 }
14023
14024 case 2: //x
14025 Xwpn = itm;
14026 game->items_off[itm] = 0;
14027 game->xwpn = itm;
14028 game->forced_xwpn = itm;
14029 break;
14030
14031 case 3: //y
14032 Ywpn = itm;
14033 game->items_off[itm] = 0;
14034 game->ywpn = itm;
14035 game->forced_ywpn = itm;
14036 break;
14037 }
14038 }
14039 }
14040 }
14041 break;
14042
14043 case LINKINVIS:
14044 740 Hero.setDontDraw((value ? 2 : 0));
14045 740 break;
14046
14047 case LINKINVINC:
14048 1532 Hero.scriptcoldet=(value/10000);
14049 1532 break;
14050
14051 case LINKENGINEANIMATE:
14052 Hero.do_animation=(value ? 1 : 0);
14053 break;
14054
14055 case LINKSWORDJINX:
14056 4 Hero.setSwordClk(value/10000);
14057 4 break;
14058
14059 case LINKITEMJINX:
14060 5161 Hero.setItemClk(value/10000);
14061 5161 break;
14062
14063 case LINKDRUNK:
14064 Hero.setDrunkClock(value/10000);
14065 break;
14066
14067 case LINKMISCD:
14068 56626 Hero.miscellaneous[vbound(ri->d[rINDEX]/10000,0,31)] = value;
14069 56626 break;
14070
14071 case LINKHITBY:
14072 {
14073 int32_t indx = ri->d[rINDEX]/10000;
14074 switch(indx)
14075 {
14076 //screen index objects
14077 case 0:
14078 case 1:
14079 case 2:
14080 case 3:
14081 case 8:
14082 case 9:
14083 case 10:
14084 case 11:
14085 case 12:
14086 case 16:
14087 {
14088 Hero.sethitHeroUID(indx, (value/10000)); //Why the Flidd did I vbound this? UIDs are LONGs, with a starting value of 0.0001. Why did I allow it, in fact? -Z
14089 break;
14090 }
14091 //UIDs
14092 case 4:
14093 case 5:
14094 case 6:
14095 case 7:
14096 case 13:
14097 case 14:
14098 case 15:
14099 {
14100 Hero.sethitHeroUID(indx, value); //Why the Flidd did I vbound this? UIDs are LONGs, with a starting value of 0.0001. Why did I allow it, in fact? -Z
14101 break;
14102 }
14103 default: { al_trace("Invalid index passed to Player->HitBy[%d] /n", indx); break; }
14104 }
14105 break;
14106 }
14107
14108 case LINKDEFENCE:
14109 Hero.set_defence(vbound(ri->d[rINDEX]/10000,0,255), ((char)vbound((value/10000), 0, 255)));
14110 break;
14111
14112 case LINKHXOFS:
14113 (Hero.hxofs)=(zfix)(value/10000);
14114 break;
14115
14116 case LINKROTATION:
14117 if ( get_qr(qr_OLDSPRITEDRAWS) )
14118 {
14119 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
14120 "Player->Rotation");
14121 break;
14122 }
14123 (Hero.rotation)=(value/10000);
14124 break;
14125
14126 case LINKSCALE:
14127 {
14128 if ( get_qr(qr_OLDSPRITEDRAWS) )
14129 {
14130 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
14131 "Player->Scale");
14132 break;
14133 }
14134 (Hero.scale)=(value/100.0);
14135 //al_trace("Player.scale is: %d\n", Hero.scale);
14136 //al_trace("Trying to set Player.scale to: %d\n", value/100.0);
14137 break;
14138 }
14139
14140 case LINKHYOFS:
14141 (Hero.hyofs)=(zfix)(value/10000);
14142 break;
14143
14144 case LINKXOFS:
14145 (Hero.xofs)=(zfix)(value/10000);
14146 break;
14147
14148 case LINKYOFS:
14149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280560 times.
280560 (Hero.yofs)=(zfix)(value/10000)+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14150 280560 break;
14151 case HEROTOTALDYOFFS:
14152 break; //READ-ONLY
14153
14154 case HEROSHADOWXOFS:
14155 (Hero.shadowxofs)=(zfix)(value/10000);
14156 break;
14157
14158 case HEROSHADOWYOFS:
14159 (Hero.shadowyofs)=(zfix)(value/10000);
14160 break;
14161
14162 case LINKZOFS:
14163 (Hero.zofs)=(zfix)(value/10000);
14164 break;
14165
14166 case LINKHXSZ:
14167 (Hero.hit_width)=(zfix)(value/10000);
14168 break;
14169
14170 case LINKHYSZ:
14171 (Hero.hit_height)=(zfix)(value/10000);
14172 break;
14173
14174 case LINKHZSZ:
14175 (Hero.hzsz)=(zfix)(value/10000);
14176 break;
14177
14178 case LINKTXSZ:
14179 (Hero.txsz)=(zfix)(value/10000);
14180 break;
14181
14182 case LINKTYSZ:
14183 (Hero.tysz)=(zfix)(value/10000);
14184 break;
14185
14186 case LINKTILE:
14187 (Hero.tile)=(zfix)(value/10000);
14188 break;
14189
14190 case LINKFLIP:
14191 (Hero.flip)=(zfix)(value/10000);
14192 break;
14193
14194
14195
14196 case LINKINVFRAME:
14197 Hero.setHClk( (int32_t)vbound((value/10000), 0, 214747) );
14198 break;
14199
14200 case LINKCANFLICKER:
14201 Hero.setCanFlicker((value/10000)?1:0);
14202 break;
14203
14204 case LINKHURTSFX:
14205 Hero.setHurtSFX( (int32_t)vbound((value/10000), 0, 255) );
14206 break;
14207
14208
14209 case LINKITEMB:
14210 {
14211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93759 times.
93759 if ( value/10000 < -1 )
14212 {
14213 al_trace("Tried to write an invalid item ID to Player->ItemB: %d\n",value/10000);
14214 break;
14215 }
14216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93759 times.
93759 if ( value/10000 > MAXITEMS-1 )
14217 {
14218 al_trace("Tried to write an invalid item ID to Player->ItemB: %d\n",value/10000);
14219 break;
14220 }
14221 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
14222
14223
2/2
✓ Branch 0 taken 93750 times.
✓ Branch 1 taken 9 times.
93759 if (Bwpn != (value/10000))
14224 {
14225 9 Bwpn = value/10000;
14226 9 int32_t wpndummy = BWeapon_to_Pos(Bwpn);
14227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (wpndummy >= 0) game->bwpn = wpndummy;
14228 9 game->forced_bwpn = value/10000;
14229 9 game->items_off[value/10000] = 0;
14230 9 }
14231 93759 directItemB = value/10000;
14232 93759 break;
14233 }
14234
14235
14236 case LINKITEMA:
14237 {
14238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93760 times.
93760 if ( value/10000 < -1 )
14239 {
14240 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemA: %d\n",value/10000);
14241 break;
14242 }
14243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93760 times.
93760 if ( value/10000 > MAXITEMS-1 )
14244 {
14245 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemA: %d\n",value/10000);
14246 break;
14247 }
14248 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
14249
2/2
✓ Branch 0 taken 93752 times.
✓ Branch 1 taken 8 times.
93760 if (Awpn != (value/10000))
14250 {
14251 8 Awpn = value/10000;
14252 8 int32_t wpndummy = BWeapon_to_Pos(Awpn);
14253
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5 times.
8 if (wpndummy >= 0) game->awpn = wpndummy;
14254 8 game->items_off[value/10000] = 0;
14255 8 game->forced_awpn = value/10000;
14256 8 }
14257 93760 directItemA = value/10000;
14258 93760 break;
14259 }
14260
14261 case LINKITEMX:
14262 {
14263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93772 times.
93772 if ( value/10000 < -1 )
14264 {
14265 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemX: %d\n",value/10000);
14266 break;
14267 }
14268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93772 times.
93772 if ( value/10000 > MAXITEMS-1 )
14269 {
14270 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemX: %d\n",value/10000);
14271 break;
14272 }
14273 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
14274
2/2
✓ Branch 0 taken 93739 times.
✓ Branch 1 taken 33 times.
93772 if (Xwpn != (value/10000))
14275 {
14276 33 Xwpn = value/10000;
14277 33 int32_t wpndummy = BWeapon_to_Pos(Xwpn);
14278
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 23 times.
33 if (wpndummy >= 0) game->xwpn = wpndummy;
14279 33 game->items_off[value/10000] = 0;
14280 33 game->forced_xwpn = value/10000;
14281 33 }
14282 93772 directItemX = value/10000;
14283 93772 break;
14284 }
14285 case LINKITEMY:
14286 {
14287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93778 times.
93778 if ( value/10000 < -1 )
14288 {
14289 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemY: %d\n",value/10000);
14290 break;
14291 }
14292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93778 times.
93778 if ( value/10000 > MAXITEMS-1 )
14293 {
14294 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemY: %d\n",value/10000);
14295 break;
14296 }
14297 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
14298
2/2
✓ Branch 0 taken 93735 times.
✓ Branch 1 taken 43 times.
93778 if (Ywpn != (value/10000))
14299 {
14300 43 Ywpn = value/10000;
14301 43 int32_t wpndummy = BWeapon_to_Pos(Ywpn);
14302
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 37 times.
43 if (wpndummy >= 0) game->ywpn = wpndummy;
14303 43 game->items_off[value/10000] = 0;
14304 43 game->forced_ywpn = value/10000;
14305 43 }
14306 93778 directItemY = value/10000;
14307 93778 break;
14308 }
14309
14310
14311 case LINKEATEN:
14312 Hero.setEaten(value/10000);
14313 break;
14314 case LINKGRABBED:
14315 Hero.inwallm = value != 0;
14316 break;
14317 case HEROBUNNY:
14318 Hero.setBunnyClock(value/10000);
14319 break;
14320 case LINKPUSH:
14321 Hero.pushing = zc_max((value/10000),0);
14322 break;
14323 case LINKSTUN:
14324 Hero.setStunClock(value/10000);
14325 break;
14326 case LINKSCRIPTTILE:
14327 2569 script_hero_sprite=vbound((value/10000), -1, NEWMAXTILES-1);
14328 2569 break;
14329
14330 case HEROSCRIPTCSET:
14331 script_hero_cset=vbound((value/10000), -1, 0xF);
14332 break;
14333 case LINKSCRIPFLIP:
14334 2569 script_hero_flip=vbound((value/10000),-1,256);
14335 2569 break;
14336
14337 case GAMESETA:
14338 {
14339 //int32_t state = (ri->d[rINDEX2]/10000);
14340 //int32_t extend = (ri->d[rINDEX2]/10000);
14341 //int32_t dir = (ri->d[rINDEX]/10000);
14342 Z_message("Trying to force-set the A-button item().\n");
14343 Hero.setAButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
14344 }
14345 break;
14346
14347 case GAMESETB:
14348 {
14349 //int32_t state = (ri->d[rINDEX2]/10000);
14350 //int32_t extend = (ri->d[rINDEX2]/10000);
14351 //int32_t dir = (ri->d[rINDEX]/10000);
14352 Z_message("Trying to force-set the A-button item().\n");
14353 Hero.setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
14354 }
14355 break;
14356
14357 //Set Hero Diagonal
14358 case LINKDIAG:
14359 Hero.setDiagMove(value?1:0);
14360 set_qr(qr_LTTPWALK, value?1:0);
14361 break;
14362
14363 //Set Hero Big Hitbox
14364 case LINKBIGHITBOX:
14365 Hero.setBigHitbox((value/10000)?1:0);
14366 set_qr(qr_LTTPCOLLISION, (value/10000)?1:0);
14367 break;
14368
14369 case LINKCLIMBING:
14370 Hero.setOnSideviewLadder(value!=0?true:false);
14371 break;
14372
14373 case HEROJUMPCOUNT:
14374 Hero.extra_jump_count = value/10000;
14375 break;
14376
14377 case HEROPULLCLK:
14378 Hero.pit_pullclk = value/10000;
14379 break;
14380 case HEROFALLCLK:
14381 {
14382 int32_t val = vbound(value/10000,0,70);
14383 if(val)
14384 Hero.setAction(falling);
14385 else if(Hero.action == falling)
14386 {
14387 Hero.setAction(none);
14388 }
14389 Hero.fallclk = val;
14390 break;
14391 }
14392 case HEROFALLCMB:
14393 Hero.fallCombo = vbound(value/10000,0,MAXCOMBOS-1);
14394 break;
14395 case HERODROWNCLK:
14396 {
14397 int32_t val = vbound(value/10000,0,70);
14398 if(val)
14399 {
14400 if (Hero.action != lavadrowning) Hero.setAction(drowning);
14401 }
14402 else if(Hero.action == drowning || Hero.action == lavadrowning)
14403 {
14404 Hero.setAction(none);
14405 }
14406 Hero.drownclk = val;
14407 break;
14408 }
14409 case HERODROWNCMB:
14410 Hero.drownCombo = vbound(value/10000,0,MAXCOMBOS-1);
14411 break;
14412 case HEROFAKEZ:
14413 {
14414 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
14415 {
14416 Hero.setFakeZfix(zslongToFix(value));
14417 }
14418 else
14419 {
14420 Hero.setFakeZ(value/10000);
14421 }
14422 }
14423 break;
14424 case HEROMOVEFLAGS:
14425 {
14426 166 int32_t indx = ri->d[rINDEX]/10000;
14427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
166 if(BC::checkBounds(indx, 0, 10, "Hero->MoveFlags[]") == SH::_NoError)
14428 {
14429 //All bits, in order, of a single byte; just use bitwise
14430 166 int32_t bit = 1<<indx;
14431
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 165 times.
166 if(value)
14432 1 Hero.moveflags |= bit;
14433 else
14434 165 Hero.moveflags &= ~bit;
14435 166 }
14436 166 break;
14437 }
14438 case HEROLIFTFLAGS:
14439 {
14440 int32_t indx = ri->d[rINDEX]/10000;
14441 if(BC::checkBounds(indx, 0, NUM_LIFTFL-1, "Hero->LiftFlags[]") == SH::_NoError)
14442 {
14443 int32_t bit = 1<<indx;
14444 if(value)
14445 Hero.liftflags |= bit;
14446 else
14447 Hero.liftflags &= ~bit;
14448 }
14449 break;
14450 }
14451
14452 case HEROSHIELDJINX:
14453 Hero.shieldjinxclk = value/10000;
14454 break;
14455
14456 case CLOCKACTIVE:
14457 {
14458 Hero.setClock(watch=(value?true:false));
14459 break;
14460 }
14461
14462 case CLOCKCLK:
14463 clockclk = vbound((value/10000), 0, 214748);
14464 break;
14465
14466 case HERORESPAWNX:
14467 {
14468 zfix zx = zslongToFix(value);
14469 Hero.respawn_x = vbound(zx, 0, 240);
14470 break;
14471 }
14472
14473 case HERORESPAWNY:
14474 {
14475 zfix zy = zslongToFix(value);
14476 Hero.respawn_y = vbound(zy, 0, 160);
14477 break;
14478 }
14479
14480 case HERORESPAWNDMAP:
14481 {
14482 Hero.respawn_dmap = vbound(value/10000, 0, MAXDMAPS-1);
14483 break;
14484 }
14485
14486 case HERORESPAWNSCR:
14487 {
14488 Hero.respawn_scr = vbound(value/10000, 0, 0x7F);
14489 break;
14490 }
14491
14492
14493 case HEROSWITCHMAXTIMER:
14494 case HEROSWITCHTIMER:
14495 break; //read-only
14496
14497 case HEROIMMORTAL:
14498 {
14499 Hero.setImmortal(value/10000);
14500 break;
14501 }
14502
14503 case HEROCOYOTETIME:
14504 {
14505 auto v = value/10000;
14506 if(v < 0 || v > 65535) v = 65535;
14507 Hero.coyotetime = word(v);
14508 break;
14509 }
14510 case HEROLIFTEDWPN:
14511 {
14512 if(Hero.lift_wpn)
14513 {
14514 delete Hero.lift_wpn;
14515 Hero.lift_wpn = nullptr;
14516 }
14517 if(value)
14518 {
14519 if(weapon* wpn = checkLWpn(value,"Hero->LiftedWeapon"))
14520 {
14521 if(wpn == Hero.lift_wpn) break;
14522 Hero.lift_wpn = wpn;
14523 if(Lwpns.find(wpn) > -1)
14524 Lwpns.remove(wpn);
14525 if(curScriptType == ScriptType::Lwpn && value == curScriptIndex)
14526 earlyretval = RUNSCRIPT_SELFREMOVE;
14527 }
14528 }
14529 break;
14530 }
14531 case HEROLIFTTIMER:
14532 {
14533 Hero.liftclk = value/10000;
14534 break;
14535 }
14536 case HEROLIFTMAXTIMER:
14537 {
14538 Hero.tliftclk = value/10000;
14539 break;
14540 }
14541 case HEROLIFTHEIGHT:
14542 {
14543 Hero.liftheight = zslongToFix(value);
14544 break;
14545 }
14546 case HEROHAMMERSTATE:
14547 {
14548 //readonly
14549 break;
14550 }
14551
14552
14553 ///----------------------------------------------------------------------------------------------------//
14554 //Input States
14555 case INPUTSTART:
14556 {
14557 928305 control_state[6]=(value?true:false);
14558
2/2
✓ Branch 0 taken 928224 times.
✓ Branch 1 taken 81 times.
928305 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[6]=false;
14559 928305 break;
14560 }
14561
14562 case INPUTMAP:
14563 {
14564 461908 control_state[9]=(value?true:false);
14565
2/2
✓ Branch 0 taken 461809 times.
✓ Branch 1 taken 99 times.
461908 if ( get_qr(qr_FIXDRUNKINPUTS) )
14566 99 drunk_toggle_state[9]=false;
14567 461908 break;
14568 }
14569
14570 case INPUTUP:
14571 {
14572 249228 control_state[0]=(value?true:false);
14573
2/2
✓ Branch 0 taken 248029 times.
✓ Branch 1 taken 1199 times.
249228 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[0]=false;
14574 249228 break;
14575 }
14576
14577 case INPUTDOWN:
14578 {
14579 249220 control_state[1]=(value?true:false);
14580
2/2
✓ Branch 0 taken 248027 times.
✓ Branch 1 taken 1193 times.
249220 if ( get_qr(qr_FIXDRUNKINPUTS) )
14581 1193 drunk_toggle_state[1]=false;
14582 249220 break;
14583 }
14584
14585 case INPUTLEFT:
14586 {
14587 236658 control_state[2]=(value?true:false);
14588
2/2
✓ Branch 0 taken 235481 times.
✓ Branch 1 taken 1177 times.
236658 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[2]=false;
14589 236658 break;
14590 }
14591
14592 case INPUTRIGHT:
14593 {
14594 236880 control_state[3]=(value?true:false);
14595
2/2
✓ Branch 0 taken 235703 times.
✓ Branch 1 taken 1177 times.
236880 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[3]=false;
14596 236880 break;
14597 }
14598
14599 case INPUTA:
14600 {
14601 89166 control_state[4]=(value?true:false);
14602
2/2
✓ Branch 0 taken 89113 times.
✓ Branch 1 taken 53 times.
89166 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[4]=false;
14603 89166 break;
14604 }
14605
14606 case INPUTB:
14607 {
14608 76223 control_state[5]=(value?true:false);
14609
1/2
✓ Branch 0 taken 76223 times.
✗ Branch 1 not taken.
76223 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[5]=false;
14610 76223 break;
14611 }
14612
14613 case INPUTL:
14614 {
14615 78737 control_state[7]=(value?true:false);
14616
2/2
✓ Branch 0 taken 78656 times.
✓ Branch 1 taken 81 times.
78737 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[7]=false;
14617 78737 break;
14618 }
14619
14620 case INPUTR:
14621 {
14622 78784 control_state[8]=(value?true:false);
14623
2/2
✓ Branch 0 taken 78703 times.
✓ Branch 1 taken 81 times.
78784 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[8]=false;
14624 78784 break;
14625 }
14626
14627 case INPUTEX1:
14628 {
14629 222649 control_state[10]=(value?true:false);
14630 222649 break;
14631 }
14632
14633 case INPUTEX2:
14634 222649 control_state[11]=(value?true:false);
14635 222649 break;
14636
14637 case INPUTEX3:
14638 222649 control_state[12]=(value?true:false);
14639 222649 break;
14640
14641 case INPUTEX4:
14642 222649 control_state[13]=(value?true:false);
14643 222649 break;
14644
14645 case INPUTAXISUP:
14646 control_state[14]=(value?true:false);
14647 break;
14648
14649 case INPUTAXISDOWN:
14650 control_state[15]=(value?true:false);
14651 break;
14652
14653 case INPUTAXISLEFT:
14654 control_state[16]=(value?true:false);
14655 break;
14656
14657 case INPUTAXISRIGHT:
14658 control_state[17]=(value?true:false);
14659 break;
14660
14661 case INPUTPRESSSTART:
14662 928305 button_press[6]=(value?true:false);
14663 928305 break;
14664
14665 case INPUTPRESSMAP:
14666 461908 button_press[9]=(value?true:false);
14667 461908 break;
14668
14669 case INPUTPRESSUP:
14670 218369 button_press[0]=(value?true:false);
14671 218369 break;
14672
14673 case INPUTPRESSDOWN:
14674 218364 button_press[1]=(value?true:false);
14675 218364 break;
14676
14677 case INPUTPRESSLEFT:
14678 218431 button_press[2]=(value?true:false);
14679 218431 break;
14680
14681 case INPUTPRESSRIGHT:
14682 218461 button_press[3]=(value?true:false);
14683 218461 break;
14684
14685 case INPUTPRESSA:
14686 83086 button_press[4]=(value?true:false);
14687 83086 break;
14688
14689 case INPUTPRESSB:
14690 70141 button_press[5]=(value?true:false);
14691 70141 break;
14692
14693 case INPUTPRESSL:
14694 75869 button_press[7]=(value?true:false);
14695 75869 break;
14696
14697 case INPUTPRESSR:
14698 75916 button_press[8]=(value?true:false);
14699 75916 break;
14700
14701 case INPUTPRESSEX1:
14702 222649 button_press[10]=(value?true:false);
14703 222649 break;
14704
14705 case INPUTPRESSEX2:
14706 222649 button_press[11]=(value?true:false);
14707 222649 break;
14708
14709 case INPUTPRESSEX3:
14710 222649 button_press[12]=(value?true:false);
14711 222649 break;
14712
14713 case INPUTPRESSEX4:
14714 222649 button_press[13]=(value?true:false);
14715 222649 break;
14716
14717 case INPUTPRESSAXISUP:
14718 button_press[14]=(value?true:false);
14719 break;
14720
14721 case INPUTPRESSAXISDOWN:
14722 button_press[15]=(value?true:false);
14723 break;
14724
14725 case INPUTPRESSAXISLEFT:
14726 button_press[16]=(value?true:false);
14727 break;
14728
14729 case INPUTPRESSAXISRIGHT:
14730 button_press[17]=(value?true:false);
14731 break;
14732
14733 case INPUTMOUSEX:
14734 {
14735 position_mouse(rti_game.local_to_global_x(value/10000), mouse_y);
14736 break;
14737 }
14738
14739 case INPUTMOUSEY:
14740 {
14741 int32_t mousequakeoffset = 56+((int32_t)(zc::math::Sin((double)(quakeclk*int64_t(2)-frame))*4));
14742 int32_t tempoffset = (quakeclk > 0) ? mousequakeoffset : (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14743 position_mouse(mouse_x, rti_game.local_to_global_y(value/10000 + tempoffset));
14744 break;
14745 }
14746
14747 case INPUTMOUSEZ:
14748 position_mouse_z(value/10000);
14749 break;
14750
14751 case FFRULE:
14752 {
14753 int32_t ruleid = vbound((ri->d[rINDEX]/10000),0,qr_MAX);
14754 set_qr(ruleid, (value?true:false));
14755 switch(ruleid)
14756 {
14757 case qr_LTTPWALK:
14758 Hero.setDiagMove(value?1:0);
14759 break;
14760 case qr_LTTPCOLLISION:
14761 Hero.setBigHitbox(value?1:0);
14762 break;
14763 case qr_ZS_NO_NEG_ARRAY:
14764 can_neg_array = !value;
14765 break;
14766 }
14767 }
14768 break;
14769
14770 case BUTTONPRESS:
14771 // DUkey, DDkey, DLkey, DRkey, Akey, Bkey, Skey, Lkey, Rkey, Pkey, Exkey1, Exkey2, Exkey3, Exkey4 };
14772 {
14773 //Read-only
14774 281179 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
14775 281179 button_press[button]=(value?true:false);
14776
4/4
✓ Branch 0 taken 220927 times.
✓ Branch 1 taken 60252 times.
✓ Branch 2 taken 42471 times.
✓ Branch 3 taken 178456 times.
281179 if ( button < 11 && get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[button]=false;
14777
14778 }
14779 281179 break;
14780
14781 case BUTTONINPUT:
14782 {
14783 //Read-only
14784 281265 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
14785 281265 control_state[button]=(value?true:false);
14786
4/4
✓ Branch 0 taken 221013 times.
✓ Branch 1 taken 60252 times.
✓ Branch 2 taken 42557 times.
✓ Branch 3 taken 178456 times.
281265 if ( button < 11 && get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[button]=false;
14787 }
14788 281265 break;
14789
14790 case BUTTONHELD:
14791 {
14792 //Read-only
14793 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
14794 button_hold[button]=(value?true:false);
14795 }
14796 break;
14797
14798 case RAWKEY:
14799 { //Game->KeyPressed[], read-only
14800 //if ( !keypressed() ) break; //Don;t return values set by setting Hero->Input/Press
14801 //hmm...no, this won;t return properly for modifier keys.
14802 int32_t keyid = ri->d[rINDEX]/10000;
14803 //key = vbound(key,0,n);
14804 _key[keyid]=key[keyid]=key_current_frame[keyid]=(value?true:false); //It isn't possible to set keys true, because polling occurs before they are set?
14805 //but they *can* be set false; ??? -Z
14806 }
14807 break;
14808
14809 case KEYINPUT:
14810 {
14811 KeyInput[ri->d[rINDEX]/10000] = (value/10000)!=0;
14812 switch(ri->d[rINDEX]/10000)
14813 {
14814 case KEY_F6: onTryQuit(); break;
14815 case KEY_F3: Paused = !Paused; break;
14816 case KEY_F4: Paused = true; Advance = true; break;
14817 }
14818 break;
14819 }
14820 case KEYPRESS:
14821 {
14822 KeyPress[ri->d[rINDEX]/10000] = (value/10000)!=0;
14823 break;
14824 }
14825
14826 case SIMULATEKEYPRESS:
14827 { //Game->KeyPressed[], read-only
14828 //if ( !keypressed() ) break; //Don;t return values set by setting Hero->Input/Press
14829 //hmm...no, this won;t return properly for modifier keys.
14830 int32_t keyid = ri->d[rINDEX]/10000;
14831 //key = vbound(key,0,n);
14832 if (value/10000) simulate_keypress(keyid << 8);
14833 }
14834 break;
14835
14836 case KEYMODIFIERS:
14837 {
14838 key_shifts = ( value/10000 );
14839 break;
14840 }
14841
14842 case KEYBINDINGS:
14843 {
14844 int32_t keyid = ri->d[rINDEX]/10000;
14845 switch(keyid)
14846 {
14847 case 0: DUkey = ( value/10000 ); break;
14848 case 1: DDkey = ( value/10000 ); break;
14849 case 2: DLkey = ( value/10000 ); break;
14850 case 3: DRkey = ( value/10000 ); break;
14851 case 4: Akey = ( value/10000 ); break;
14852 case 5: Bkey = ( value/10000 ); break;
14853 case 6: Skey = ( value/10000 ); break;
14854 case 7: Lkey = ( value/10000 ); break;
14855 case 8: Rkey = ( value/10000 ); break;
14856 case 9: Pkey = ( value/10000 ); /*map*/ break;
14857 case 10: Exkey1 = ( value/10000 ); break;
14858 case 11: Exkey2 = ( value/10000 ); break;
14859 case 12: Exkey3 = ( value/10000 ); break;
14860 case 13: Exkey4 = ( value/10000 ); break;
14861
14862 default: { Z_scripterrlog("Invalid index [%d] passed to Input->KeyBindings[]\n", keyid); break; }
14863 }
14864 break;
14865 }
14866
14867 case DISABLEKEY:
14868 {
14869 //Input->DisableKey(int32_t key, bool disable)
14870 int32_t keyid = ri->d[rINDEX]/10000;
14871 if(!zc_disablekey(keyid, value))
14872 {
14873 //Z_scripterrlog("The key %d passed to Input->DisableKey[] is system-reserved, and cannot be disabled\n",keyid);
14874 }
14875 break;
14876 }
14877
14878 case DISABLEBUTTON:
14879 {
14880 //Input->DisableButton(int32_t cb, bool disable)
14881 int32_t cbid = ri->d[rINDEX]/10000;
14882 disable_control[cbid] = value?true:false;
14883 break;
14884 }
14885
14886 case MOUSEARR:
14887 {
14888 int32_t indx = (ri->d[rINDEX]/10000);
14889 switch (indx)
14890 {
14891 case 0: //MouseX
14892 {
14893 position_mouse(rti_game.local_to_global_x(value/10000), mouse_y);
14894 break;
14895 }
14896 case 1: //MouseY
14897 {
14898 int32_t mousequakeoffset = 56+((int32_t)(zc::math::Sin((double)(quakeclk*int64_t(2)-frame))*4));
14899 int32_t tempoffset = (quakeclk > 0) ? mousequakeoffset :(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14900 position_mouse(mouse_x, rti_game.local_to_global_y(value/10000 + tempoffset));
14901 break;
14902
14903 }
14904 case 2: //MouseZ
14905 {
14906 position_mouse_z(value/10000);
14907 break;
14908 }
14909 case 3: //Left Click
14910 {
14911 if ( value ) mouse_b |= 1;
14912 else mouse_b &= ~1;
14913 break;
14914 }
14915 case 4: //Right Click
14916 {
14917 if ( value ) mouse_b |= 2;
14918 else mouse_b &= ~2;
14919 break;
14920 }
14921 case 5: //Middle Click
14922 {
14923 if ( value ) mouse_b |= 4;
14924 else mouse_b &= ~4;
14925 break;
14926 }
14927 default:
14928 {
14929 Z_scripterrlog("Invalid index passed to Input->Mouse[]: %d\n", indx);
14930 }
14931 }
14932
14933 }
14934 break;
14935
14936
14937 ///----------------------------------------------------------------------------------------------------//
14938 //Item Variables
14939
14940 case ITEMFAMILY:
14941 if(0!=(s=checkItem(ri->itemref)))
14942 {
14943 (((item *)s)->family)=value/10000;
14944 }
14945
14946 break;
14947
14948 case ITEMLEVEL:
14949 if(0!=(s=checkItem(ri->itemref)))
14950 {
14951 (((item *)s)->lvl)=value/10000;
14952 }
14953
14954 break;
14955
14956 case SPRITEMAXITEM:
14957 {
14958 //No bounds check, as this is a universal function and works from NULL pointers!
14959 items.setMax(vbound((value/10000),1,MAX_ITEM_SPRITES));
14960 break;
14961 }
14962
14963 case ITEMX:
14964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21848 times.
21848 if(0!=(s=checkItem(ri->itemref)))
14965 {
14966
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 21678 times.
21848 (s->x)=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
14967
14968 // Move the Fairy enemy as well.
14969
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 21838 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
21848 if(itemsbuf[((item*)(s))->id].family==itype_fairy && itemsbuf[((item*)(s))->id].misc3)
14970 movefairynew2(((item*)(s))->x,((item*)(s))->y,*((item*)(s)));
14971 21848 }
14972
14973 21848 break;
14974
14975 case ITEMSPRITESCRIPT:
14976 31 FFScript::deallocateAllArrays(ScriptType::ItemSprite, ri->itemref);
14977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(0!=(s=checkItem(ri->itemref)))
14978 {
14979 31 (s->script)=(value/10000);
14980 31 }
14981 31 break;
14982
14983 case ITEMSCALE:
14984 if ( get_qr(qr_OLDSPRITEDRAWS) )
14985 {
14986 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
14987 "item->Scale");
14988 break;
14989 }
14990 if(0!=(s=checkItem(ri->itemref)))
14991 {
14992 (s->scale)=(zfix)(value/100.0);
14993 }
14994
14995 break;
14996
14997 case ITEMY:
14998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41791 times.
41791 if(0!=(s=checkItem(ri->itemref)))
14999 {
15000
2/2
✓ Branch 0 taken 1142 times.
✓ Branch 1 taken 40649 times.
41791 (s->y)=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
15001
15002 // Move the Fairy enemy as well.
15003
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 41781 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
41791 if(itemsbuf[((item*)(s))->id].family==itype_fairy && itemsbuf[((item*)(s))->id].misc3)
15004 movefairynew2(((item*)(s))->x,((item*)(s))->y,*((item*)(s)));
15005 41791 }
15006
15007 41791 break;
15008
15009 case ITEMZ:
15010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(0!=(s=checkItem(ri->itemref)))
15011 {
15012 92 (s->z)=(zfix)(value/10000);
15013
15014
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(s->z < 0)
15015 s->z = 0;
15016 92 }
15017
15018 92 break;
15019
15020 case ITEMJUMP:
15021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49959 times.
49959 if(0!=(s=checkItem(ri->itemref)))
15022 {
15023 49959 (((item *)s)->fall)=zslongToFix(value)*-100;
15024 49959 }
15025
15026 49959 break;
15027
15028 case ITEMFAKEJUMP:
15029 if(0!=(s=checkItem(ri->itemref)))
15030 {
15031 (((item *)s)->fakefall)=zslongToFix(value)*-100;
15032 }
15033
15034 break;
15035
15036 case ITEMDRAWTYPE:
15037 if(0!=(s=checkItem(ri->itemref)))
15038 {
15039 (((item *)s)->drawstyle)=value/10000;
15040 }
15041
15042 break;
15043
15044 case ITEMSPRITEINITD:
15045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(0!=(s=checkItem(ri->itemref)))
15046 {
15047 37 int32_t a = vbound(ri->d[rINDEX]/10000,0,7);
15048 37 (((item *)s)->initD[a])=value;
15049 37 }
15050
15051 37 break;
15052
15053 case ITEMGRAVITY:
15054 if(0!=(s=checkItem(ri->itemref)))
15055 {
15056 if(value)
15057 ((item *)s)->moveflags |= FLAG_OBEYS_GRAV;
15058 else
15059 ((item *)s)->moveflags &= ~FLAG_OBEYS_GRAV;
15060 }
15061
15062 break;
15063
15064 case ITEMID:
15065 if(0!=(s=checkItem(ri->itemref)))
15066 {
15067 (((item *)s)->id)=value/10000;
15068 flushItemCache();
15069 }
15070
15071 break;
15072
15073 case ITEMTILE:
15074
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if(0!=(s=checkItem(ri->itemref)))
15075 {
15076 109 (((item *)s)->tile)=vbound(value/10000,0,NEWMAXTILES-1);
15077 109 }
15078
15079 109 break;
15080
15081 case ITEMSCRIPTTILE:
15082 if(0!=(s=checkItem(ri->itemref)))
15083 {
15084 (((item *)s)->scripttile)=vbound(value/10000,-1,NEWMAXTILES-1);
15085 }
15086 break;
15087
15088 case ITEMSCRIPTFLIP:
15089 if(0!=(s=checkItem(ri->itemref)))
15090 {
15091 (((item *)s)->scriptflip)=vbound((value/10000),-1,127);
15092 }
15093 break;
15094
15095 case ITEMPSTRING:
15096 if(0!=(s=checkItem(ri->itemref)))
15097 {
15098 (((item *)s)->pstring)=vbound(value/10000,0,(msg_count-1));
15099 }
15100
15101 break;
15102
15103 case ITEMPSTRINGFLAGS:
15104 if(0!=(s=checkItem(ri->itemref)))
15105 {
15106 (((item *)s)->pickup_string_flags)=vbound(value/10000, 0, 214748);
15107 }
15108
15109 break;
15110
15111 case ITEMOVERRIDEFLAGS:
15112 break;
15113
15114 case ITEMOTILE:
15115
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(0!=(s=checkItem(ri->itemref)))
15116 {
15117 40 (((item *)s)->o_tile)=vbound(value/10000,0,NEWMAXTILES-1);
15118 40 }
15119
15120 40 break;
15121
15122 case ITEMCSET:
15123 if(0!=(s=checkItem(ri->itemref)))
15124 {
15125 (((item *)s)->o_cset) = (((item *)s)->o_cset & ~15) | ((value/10000)&15);
15126 (((item *)s)->cs) = (((item *)s)->o_cset & 15);
15127 }
15128
15129 break;
15130
15131 case ITEMFLASHCSET:
15132 if(0!=(s=checkItem(ri->itemref)))
15133 {
15134 (((item *)s)->o_cset) = ((value/10000)<<4) | (((item *)s)->o_cset & 15);
15135 }
15136
15137 break;
15138
15139 case ITEMFRAMES:
15140 if(0!=(s=checkItem(ri->itemref)))
15141 {
15142 (((item *)s)->frames)=value/10000;
15143 }
15144
15145 break;
15146
15147 case ITEMFRAME:
15148 if(0!=(s=checkItem(ri->itemref)))
15149 {
15150 (((item *)s)->aframe)=value/10000;
15151 }
15152
15153 break;
15154
15155 case ITEMASPEED:
15156 if(0!=(s=checkItem(ri->itemref)))
15157 {
15158 (((item *)s)->o_speed)=value/10000;
15159 }
15160
15161 break;
15162
15163 case ITEMACLK:
15164 if(0!=(s=checkItem(ri->itemref)))
15165 {
15166 (((item *)s)->aclk)=value/10000;
15167 }
15168
15169 break;
15170
15171 case ITEMDELAY:
15172 if(0!=(s=checkItem(ri->itemref)))
15173 {
15174 (((item *)s)->o_delay)=value/10000;
15175 }
15176
15177 break;
15178
15179 case ITEMFLIP:
15180 if(0!=(s=checkItem(ri->itemref)))
15181 {
15182 (((item *)s)->flip)=value/10000;
15183 }
15184
15185 break;
15186
15187 case ITEMFLASH:
15188 if(0!=(s=checkItem(ri->itemref)))
15189 {
15190 (((item *)s)->flash)= (value/10000)?1:0;
15191 }
15192
15193 break;
15194
15195 case ITEMEXTEND:
15196 if(0!=(s=checkItem(ri->itemref)))
15197 {
15198 (((item *)s)->extend)=value/10000;
15199 }
15200
15201 break;
15202
15203 case ITEMHXOFS:
15204 if(0!=(s=checkItem(ri->itemref)))
15205 {
15206 ((item*)(s))->hxofs=value/10000;
15207 }
15208
15209 break;
15210
15211 case ITEMROTATION:
15212 if ( get_qr(qr_OLDSPRITEDRAWS) )
15213 {
15214 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
15215 "item->Rotation");
15216 break;
15217 }
15218 if(0!=(s=checkItem(ri->itemref)))
15219 {
15220 ((item*)(s))->rotation=value/10000;
15221 }
15222
15223 break;
15224
15225 case ITEMHYOFS:
15226 if(0!=(s=checkItem(ri->itemref)))
15227 {
15228 ((item*)(s))->hyofs=value/10000;
15229 }
15230
15231 break;
15232
15233 case ITEMXOFS:
15234 if(0!=(s=checkItem(ri->itemref)))
15235 {
15236 ((item*)(s))->xofs=(zfix)(value/10000);
15237 }
15238
15239 break;
15240
15241 case ITEMYOFS:
15242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(0!=(s=checkItem(ri->itemref)))
15243 {
15244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 ((item*)(s))->yofs=(zfix)(value/10000)+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15245 6 }
15246
15247 6 break;
15248
15249 case ITEMSHADOWXOFS:
15250 if(0!=(s=checkItem(ri->itemref)))
15251 {
15252 ((item*)(s))->shadowxofs=(zfix)(value/10000);
15253 }
15254
15255 break;
15256
15257 case ITEMSHADOWYOFS:
15258 if(0!=(s=checkItem(ri->itemref)))
15259 {
15260 ((item*)(s))->shadowyofs=(zfix)(value/10000);
15261 }
15262
15263 break;
15264
15265 case ITEMZOFS:
15266 if(0!=(s=checkItem(ri->itemref)))
15267 {
15268 ((item*)(s))->zofs=(zfix)(value/10000);
15269 }
15270
15271 break;
15272
15273 case ITEMHXSZ:
15274 if(0!=(s=checkItem(ri->itemref)))
15275 {
15276 ((item*)(s))->hit_width=value/10000;
15277 }
15278
15279 break;
15280
15281 case ITEMHYSZ:
15282 if(0!=(s=checkItem(ri->itemref)))
15283 {
15284 ((item*)(s))->hit_height=value/10000;
15285 }
15286
15287 break;
15288
15289 case ITEMHZSZ:
15290 if(0!=(s=checkItem(ri->itemref)))
15291 {
15292 ((item*)(s))->hzsz=value/10000;
15293 }
15294
15295 break;
15296
15297 case ITEMTXSZ:
15298 if(0!=(s=checkItem(ri->itemref)))
15299 {
15300 ((item*)(s))->txsz=vbound((value/10000),1,20);
15301 }
15302
15303 break;
15304
15305 case ITEMTYSZ:
15306 if(0!=(s=checkItem(ri->itemref)))
15307 {
15308 ((item*)(s))->tysz=vbound((value/10000),1,20);
15309 }
15310
15311 break;
15312
15313 case ITEMPICKUP:
15314
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 1181 times.
787 if(0!=(s=checkItem(ri->itemref)))
15315 {
15316 1181 int32_t newpickup = value/10000;
15317 // Values that the questmaker should not use, ever
15318 //Allowing it, for now, until something breaks. -Z 21-Jan-2020
15319 //newpickup &= ~(ipBIGRANGE | ipCHECK | ipMONEY | ipBIGTRI | ipNODRAW | ipFADE);
15320 //
15321
4/4
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 461 times.
✓ Branch 2 taken 197 times.
✓ Branch 3 taken 264 times.
1181 if (( FFCore.GetQuestVersion() == 0x250 && FFCore.GetQuestBuild() < 33 ) //this ishowit looks in 2.53.1, Beta 25
15322 1181 || ( FFCore.GetQuestVersion() < 0x250 ))
15323 {
15324 917 newpickup &= ~(ipBIGRANGE | ipCHECK | ipMONEY | ipBIGTRI | ipNODRAW | ipFADE);
15325 917 }
15326
15327 // If making an item timeout, set its timer
15328
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 70 times.
787 if(newpickup & ipFADE)
15329 {
15330 70 (((item*)(s))->clk2) = 512;
15331 70 }
15332 //else if(newpickup & ~ipFADE)
15333 //{
15334 // (((item*)(s))->clk2) = 0;
15335 //}
15336
15337 // If making it a carried item,
15338 // alter hasitem and set an itemguy.
15339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
787 if((((item*)(s))->pickup & ipENEMY) < (newpickup & ipENEMY))
15340 {
15341 hasitem |= 2;
15342 bool hasitemguy = false;
15343
15344 for(int32_t i=0; i<guys.Count(); i++)
15345 {
15346 if(((enemy*)guys.spr(i))->itemguy)
15347 {
15348 hasitemguy = true;
15349 }
15350 }
15351
15352 if(!hasitemguy && guys.Count()>0)
15353 {
15354 ((enemy*)guys.spr(guys.Count()-1))->itemguy = true;
15355 }
15356 }
15357 // If unmaking it a carried item,
15358 // alter hasitem if there are no more carried items.
15359
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 else if((((item*)(s))->pickup & ipENEMY) > (newpickup & ipENEMY))
15360 {
15361 // Move it back onscreen!
15362 if(get_qr(qr_HIDECARRIEDITEMS))
15363 {
15364 for(int32_t i=0; i<guys.Count(); i++)
15365 {
15366 if(((enemy*)guys.spr(i))->itemguy)
15367 {
15368 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
15369 {
15370 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
15371 {
15372 ((item*)(s))->x = ((enemy*)guys.spr(i))->x+((enemy*)guys.spr(i))->hxofs+(((enemy*)guys.spr(i))->hit_width/2)-8;
15373 ((item*)(s))->y = ((enemy*)guys.spr(i))->y+((enemy*)guys.spr(i))->hyofs+(((enemy*)guys.spr(i))->hit_height/2)-10;
15374 ((item*)(s))->z = ((enemy*)guys.spr(i))->z;
15375 }
15376 else
15377 {
15378 if(((enemy*)guys.spr(i))->extend >= 3)
15379 {
15380 ((item*)(s))->x = ((enemy*)guys.spr(i))->x+(((enemy*)guys.spr(i))->txsz-1)*8;
15381 ((item*)(s))->y = ((enemy*)guys.spr(i))->y-2+(((enemy*)guys.spr(i))->tysz-1)*8;
15382 ((item*)(s))->z = ((enemy*)guys.spr(i))->z;
15383 }
15384 else
15385 {
15386 ((item*)(s))->x = ((enemy*)guys.spr(i))->x;
15387 ((item*)(s))->y = ((enemy*)guys.spr(i))->y - 2;
15388 ((item*)(s))->z = ((enemy*)guys.spr(i))->z;
15389 }
15390 }
15391 }
15392 else
15393 {
15394 ((item*)(s))->x = ((enemy*)guys.spr(i))->x;
15395 ((item*)(s))->y = ((enemy*)guys.spr(i))->y - 2;
15396 ((item*)(s))->z = ((enemy*)guys.spr(i))->z;
15397 }
15398 break;
15399 }
15400 }
15401 }
15402
15403 if(more_carried_items()<=1) // 1 includes this own item.
15404 {
15405 hasitem &= ~2;
15406 }
15407 }
15408
15409 787 ((item*)(s))->pickup=value/10000;
15410 787 }
15411
15412 1181 break;
15413
15414 case ITEMMISCD:
15415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3013 times.
3013 if(0!=(s=checkItem(ri->itemref)))
15416 {
15417 3013 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
15418 3013 (((item*)(s))->miscellaneous[a])=value;
15419 3013 }
15420
15421 3013 break;
15422 case ITEMFALLCLK:
15423 if(0!=(s=checkItem(ri->itemref)))
15424 {
15425 if(((item*)(s))->fallclk != 0 && value == 0)
15426 {
15427 ((item*)(s))->cs = ((item*)(s))->old_cset;
15428 ((item*)(s))->tile = ((item*)(s))->o_tile;
15429 }
15430 else if(((item*)(s))->fallclk == 0 && value != 0) ((item*)(s))->old_cset = ((item*)(s))->cs;
15431 ((item*)(s))->fallclk = vbound(value/10000,0,70);
15432 }
15433 break;
15434 case ITEMFALLCMB:
15435 if(0!=(s=checkItem(ri->itemref)))
15436 {
15437 ((item*)(s))->fallCombo = vbound(value/10000,0,MAXCOMBOS-1);
15438 }
15439 break;
15440 case ITEMDROWNCLK:
15441 if(0!=(s=checkItem(ri->itemref)))
15442 {
15443 if(((item*)(s))->drownclk != 0 && value == 0)
15444 {
15445 ((item*)(s))->cs = ((item*)(s))->old_cset;
15446 ((item*)(s))->tile = ((item*)(s))->o_tile;
15447 }
15448 else if(((item*)(s))->drownclk == 0 && value != 0) ((item*)(s))->old_cset = ((item*)(s))->cs;
15449 ((item*)(s))->drownclk = vbound(value/10000,0,70);
15450 }
15451 break;
15452 case ITEMDROWNCMB:
15453 if(0!=(s=checkItem(ri->itemref)))
15454 {
15455 ((item*)(s))->drownCombo = vbound(value/10000,0,MAXCOMBOS-1);
15456 }
15457 break;
15458 case ITEMFAKEZ:
15459 if(0!=(s=checkItem(ri->itemref)))
15460 {
15461 (s->fakez)=(zfix)(value/10000);
15462
15463 if(s->fakez < 0)
15464 s->fakez = 0;
15465 }
15466
15467 break;
15468
15469 case ITEMMOVEFLAGS:
15470 {
15471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(0!=(s=checkItem(ri->itemref)))
15472 {
15473 68 int32_t indx = ri->d[rINDEX]/10000;
15474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(BC::checkBounds(indx, 0, 10, "itemsprite->MoveFlags[]") == SH::_NoError)
15475 {
15476 //All bits, in order, of a single byte; just use bitwise
15477 68 int32_t bit = 1<<indx;
15478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(value)
15479 ((item*)(s))->moveflags |= bit;
15480 else
15481 68 ((item*)(s))->moveflags &= ~bit;
15482 68 }
15483 68 }
15484 68 break;
15485 }
15486
15487 case ITEMGLOWRAD:
15488 if(0!=(s=checkItem(ri->itemref)))
15489 {
15490 ((item*)(s))->glowRad = vbound(value/10000,0,255);
15491 }
15492 break;
15493
15494 case ITEMGLOWSHP:
15495 if(0!=(s=checkItem(ri->itemref)))
15496 {
15497 ((item*)(s))->glowShape = vbound(value/10000,0,255);
15498 }
15499 break;
15500
15501 case ITEMDIR:
15502 if(0!=(s=checkItem(ri->itemref)))
15503 {
15504 ((item*)(s))->dir=(value/10000);
15505 }
15506 break;
15507
15508 case ITEMENGINEANIMATE:
15509 if(0!=(s=checkItem(ri->itemref)))
15510 {
15511 ((item*)(s))->do_animation=(value ? 1 : 0);
15512 }
15513 break;
15514
15515 case ITEMSHADOWSPR:
15516 if(0!=(s=checkItem(ri->itemref)))
15517 {
15518 ((item*)(s))->spr_shadow=vbound(value/10000,0,255);
15519 }
15520 break;
15521 case ITEMDROPPEDBY:
15522 if(0!=(s=checkItem(ri->itemref)))
15523 {
15524 ((item*)(s))->from_dropset=vbound(value/10000,-1,255);
15525 }
15526 break;
15527 case ITMSWHOOKED:
15528 break; //read-only
15529 case ITEMFORCEGRAB:
15530 if(0!=(s=checkItem(ri->itemref)))
15531 {
15532 ((item*)(s))->set_forcegrab(value!=0);
15533 }
15534 break;
15535
15536 ///----------------------------------------------------------------------------------------------------//
15537 //Itemdata Variables
15538 //not mine, but let;s guard some of them all the same -Z
15539 //item class
15540 case IDATAFAMILY:
15541 if(unsigned(ri->idata) >= MAXITEMS)
15542 {
15543 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15544 break;
15545 }
15546 (itemsbuf[ri->idata].family)=vbound(value/10000,0, 254);
15547 flushItemCache();
15548 break;
15549
15550 case IDATAUSEWPN:
15551 if(unsigned(ri->idata) >= MAXITEMS)
15552 {
15553 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15554 break;
15555 }
15556 (itemsbuf[ri->idata].useweapon)=vbound(value/10000, 0, 255);
15557 break;
15558 case IDATAUSEDEF:
15559 if(unsigned(ri->idata) >= MAXITEMS)
15560 {
15561 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15562 break;
15563 }
15564 (itemsbuf[ri->idata].usedefence)=vbound(value/10000, 0, 255);
15565 break;
15566 case IDATAWRANGE:
15567 if(unsigned(ri->idata) >= MAXITEMS)
15568 {
15569 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15570 break;
15571 }
15572 (itemsbuf[ri->idata].weaprange)=vbound(value/10000, 0, 255);
15573 break;
15574 case IDATAMAGICTIMER:
15575 if(unsigned(ri->idata) >= MAXITEMS)
15576 {
15577 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15578 break;
15579 }
15580 (itemsbuf[ri->idata].magiccosttimer[0])=vbound(value/10000, 0, 214747);
15581 break;
15582 case IDATAMAGICTIMER2:
15583 if(unsigned(ri->idata) >= MAXITEMS)
15584 {
15585 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15586 break;
15587 }
15588 (itemsbuf[ri->idata].magiccosttimer[1])=vbound(value/10000, 0, 214747);
15589 break;
15590 case IDATADURATION:
15591 if(unsigned(ri->idata) >= MAXITEMS)
15592 {
15593 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15594 break;
15595 }
15596 (itemsbuf[ri->idata].weapduration)=vbound(value/10000, 0, 255);
15597 break;
15598
15599 case IDATADUPLICATES:
15600 if(unsigned(ri->idata) >= MAXITEMS)
15601 {
15602 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15603 break;
15604 }
15605 (itemsbuf[ri->idata].duplicates)=vbound(value/10000, 0, 255);
15606 break;
15607 case IDATADRAWLAYER:
15608 if(unsigned(ri->idata) >= MAXITEMS)
15609 {
15610 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15611 break;
15612 }
15613 (itemsbuf[ri->idata].drawlayer)=vbound(value/10000, 0, 7);
15614 break;
15615 case IDATACOLLECTFLAGS:
15616 if(unsigned(ri->idata) >= MAXITEMS)
15617 {
15618 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15619 break;
15620 }
15621 //int32_t a = ri->d[rINDEX] / 10000;
15622 (itemsbuf[ri->idata].collectflags)=vbound(value/10000, 0, 214747);
15623 break;
15624 case IDATAWEAPONSCRIPT:
15625 if(unsigned(ri->idata) >= MAXITEMS)
15626 {
15627 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15628 break;
15629 }
15630 (itemsbuf[ri->idata].weaponscript)=vbound(value/10000, 0, 255);
15631 break;
15632 case IDATAMISCD:
15633 {
15634 if(unsigned(ri->idata) >= MAXITEMS)
15635 {
15636 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15637 break;
15638 }
15639 int32_t a = vbound((ri->d[rINDEX] / 10000),0,31);
15640 (itemsbuf[ri->idata].wpn_misc_d[a])=(value/10000);
15641 }
15642 break;
15643 case IDATAWPNINITD:
15644 {
15645 if(unsigned(ri->idata) >= MAXITEMS)
15646 {
15647 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15648 break;
15649 }
15650 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
15651 (itemsbuf[ri->idata].weap_initiald[a])=(value);
15652 }
15653 break;
15654 case IDATAWEAPHXOFS:
15655 if(unsigned(ri->idata) >= MAXITEMS)
15656 {
15657 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15658 break;
15659 }
15660 (itemsbuf[ri->idata].weap_hxofs)=(value/10000);
15661 break;
15662 case IDATAWEAPHYOFS:
15663 if(unsigned(ri->idata) >= MAXITEMS)
15664 {
15665 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15666 break;
15667 }
15668 (itemsbuf[ri->idata].weap_hyofs)=(value/10000);
15669 break;
15670 case IDATAWEAPHXSZ:
15671 if(unsigned(ri->idata) >= MAXITEMS)
15672 {
15673 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15674 break;
15675 }
15676 (itemsbuf[ri->idata].weap_hxsz)=(value/10000);
15677 break;
15678 case IDATAWEAPHYSZ:
15679 if(unsigned(ri->idata) >= MAXITEMS)
15680 {
15681 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15682 break;
15683 }
15684 (itemsbuf[ri->idata].weap_hysz)=(value/10000);
15685 break;
15686 case IDATAWEAPHZSZ:
15687 if(unsigned(ri->idata) >= MAXITEMS)
15688 {
15689 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15690 break;
15691 }
15692 (itemsbuf[ri->idata].weap_hzsz)=(value/10000);
15693 break;
15694 case IDATAWEAPXOFS:
15695 if(unsigned(ri->idata) >= MAXITEMS)
15696 {
15697 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15698 break;
15699 }
15700 (itemsbuf[ri->idata].weap_xofs)=(value/10000);
15701 break;
15702 case IDATAWEAPYOFS:
15703 if(unsigned(ri->idata) >= MAXITEMS)
15704 {
15705 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15706 break;
15707 }
15708 (itemsbuf[ri->idata].weap_yofs)=(value/10000);
15709 break;
15710
15711
15712 case IDATAHXOFS:
15713 if(unsigned(ri->idata) >= MAXITEMS)
15714 {
15715 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15716 break;
15717 }
15718 (itemsbuf[ri->idata].hxofs)=(value/10000);
15719 break;
15720 case IDATAHYOFS:
15721 if(unsigned(ri->idata) >= MAXITEMS)
15722 {
15723 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15724 break;
15725 }
15726 (itemsbuf[ri->idata].hyofs)=(value/10000);
15727 break;
15728 case IDATAHXSZ:
15729 if(unsigned(ri->idata) >= MAXITEMS)
15730 {
15731 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15732 break;
15733 }
15734 (itemsbuf[ri->idata].hxsz)=(value/10000);
15735 break;
15736 case IDATAHYSZ:
15737 if(unsigned(ri->idata) >= MAXITEMS)
15738 {
15739 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15740 break;
15741 }
15742 (itemsbuf[ri->idata].hysz)=(value/10000);
15743 break;
15744 case IDATAHZSZ:
15745 if(unsigned(ri->idata) >= MAXITEMS)
15746 {
15747 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15748 break;
15749 }
15750 (itemsbuf[ri->idata].hzsz)=(value/10000);
15751 break;
15752 case IDATADXOFS:
15753 if(unsigned(ri->idata) >= MAXITEMS)
15754 {
15755 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15756 break;
15757 }
15758 (itemsbuf[ri->idata].xofs)=(value/10000);
15759 break;
15760 case IDATADYOFS:
15761 if(unsigned(ri->idata) >= MAXITEMS)
15762 {
15763 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15764 break;
15765 }
15766 (itemsbuf[ri->idata].yofs)=(value/10000);
15767 break;
15768 case IDATATILEW:
15769 if(unsigned(ri->idata) >= MAXITEMS)
15770 {
15771 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15772 break;
15773 }
15774 (itemsbuf[ri->idata].tilew)=(value/10000);
15775 break;
15776 case IDATATILEH:
15777 if(unsigned(ri->idata) >= MAXITEMS)
15778 {
15779 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15780 break;
15781 }
15782 (itemsbuf[ri->idata].tileh)=(value/10000);
15783 break;
15784 case IDATAPICKUP:
15785 if(unsigned(ri->idata) >= MAXITEMS)
15786 {
15787 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15788 break;
15789 }
15790 (itemsbuf[ri->idata].pickup)=(value/10000);
15791 break;
15792 case IDATAOVERRIDEFL:
15793 if(unsigned(ri->idata) >= MAXITEMS)
15794 {
15795 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15796 break;
15797 }
15798 (itemsbuf[ri->idata].overrideFLAGS)=(value/10000);
15799 break;
15800
15801 case IDATATILEWWEAP:
15802 if(unsigned(ri->idata) >= MAXITEMS)
15803 {
15804 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15805 break;
15806 }
15807 (itemsbuf[ri->idata].weap_tilew)=(value/10000);
15808 break;
15809 case IDATATILEHWEAP:
15810 if(unsigned(ri->idata) >= MAXITEMS)
15811 {
15812 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15813 break;
15814 }
15815 (itemsbuf[ri->idata].weap_tileh)=(value/10000);
15816 break;
15817 case IDATAOVERRIDEFLWEAP:
15818 if(unsigned(ri->idata) >= MAXITEMS)
15819 {
15820 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15821 break;
15822 }
15823 (itemsbuf[ri->idata].weapoverrideFLAGS)=(value/10000);
15824 break;
15825
15826 case IDATAUSEMVT:
15827 {
15828 if(unsigned(ri->idata) >= MAXITEMS)
15829 {
15830 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15831 break;
15832 }
15833 int32_t a = vbound((ri->d[rINDEX] / 10000),0,(ITEM_MOVEMENT_PATTERNS-1));
15834 (itemsbuf[ri->idata].weap_pattern[a])=vbound(value/10000, 0, 255);
15835 break;
15836 }
15837
15838 case IDATALEVEL:
15839 if(unsigned(ri->idata) >= MAXITEMS)
15840 {
15841 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15842 break;
15843 }
15844 (itemsbuf[ri->idata].fam_type)=vbound(value/10000, 0, 512);
15845 flushItemCache();
15846 break;
15847 case IDATAKEEP:
15848 item_flag(ITEM_GAMEDATA, value);
15849 break;
15850 case IDATAAMOUNT:
15851 {
15852 if(unsigned(ri->idata) >= MAXITEMS)
15853 {
15854 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15855 break;
15856 }
15857 int32_t v = vbound(value/10000, -9999, 16383);
15858 itemsbuf[ri->idata].amount &= 0x8000;
15859 itemsbuf[ri->idata].amount |= (abs(v)&0x3FFF)|(v<0?0x4000:0);
15860 break;
15861 }
15862 case IDATAGRADUAL:
15863 {
15864 if(unsigned(ri->idata) >= MAXITEMS)
15865 {
15866 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15867 break;
15868 }
15869 SETFLAG(itemsbuf[ri->idata].amount, 0x8000, value!=0);
15870 break;
15871 }
15872 case IDATACONSTSCRIPT:
15873 item_flag(ITEM_PASSIVESCRIPT, value);
15874 break;
15875 case IDATASSWIMDISABLED:
15876 item_flag(ITEM_SIDESWIM_DISABLED, value);
15877 break;
15878 case IDATABUNNYABLE:
15879 item_flag(ITEM_BUNNY_ENABLED, value);
15880 break;
15881 case IDATAJINXIMMUNE:
15882 item_flag(ITEM_JINX_IMMUNE, value);
15883 break;
15884 case IDATAJINXSWAP:
15885 item_flag(ITEM_FLIP_JINX, value);
15886 break;
15887 case IDATASETMAX:
15888 if(unsigned(ri->idata) >= MAXITEMS)
15889 {
15890 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15891 break;
15892 }
15893 (itemsbuf[ri->idata].setmax)=value/10000;
15894 break;
15895
15896 case IDATAMAX:
15897 if(unsigned(ri->idata) >= MAXITEMS)
15898 {
15899 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15900 break;
15901 }
15902 (itemsbuf[ri->idata].max)=value/10000;
15903 break;
15904
15905 case IDATAPOWER:
15906 if(unsigned(ri->idata) >= MAXITEMS)
15907 {
15908 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15909 break;
15910 }
15911 (itemsbuf[ri->idata].power)=value/10000;
15912 break;
15913
15914 case IDATACOUNTER:
15915 if(unsigned(ri->idata) >= MAXITEMS)
15916 {
15917 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15918 break;
15919 }
15920 (itemsbuf[ri->idata].count)=vbound(value/10000,0,31);
15921 break;
15922
15923 case IDATAPSOUND:
15924 if(unsigned(ri->idata) >= MAXITEMS)
15925 {
15926 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15927 break;
15928 }
15929 (itemsbuf[ri->idata].playsound)=vbound(value/10000, 0, 255);
15930 break;
15931
15932 case IDATAUSESOUND:
15933 if(unsigned(ri->idata) >= MAXITEMS)
15934 {
15935 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15936 break;
15937 }
15938 (itemsbuf[ri->idata].usesound)=vbound(value/10000, 0, 255);
15939 break;
15940
15941 case IDATAUSESOUND2:
15942 if(unsigned(ri->idata) >= MAXITEMS)
15943 {
15944 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15945 break;
15946 }
15947 (itemsbuf[ri->idata].usesound2)=vbound(value/10000, 0, 255);
15948 break;
15949
15950 //2.54
15951 //My additions begin here. -Z
15952 //Stack item to gain next level
15953 case IDATACOMBINE:
15954 item_flag(ITEM_COMBINE, value);
15955 break;
15956 //using a level of an item downgrades to a lower one
15957 case IDATADOWNGRADE:
15958 item_flag(ITEM_DOWNGRADE, value);
15959 break;
15960 //Only validate the cost, don't charge it
15961 case IDATAVALIDATE:
15962 item_flag(ITEM_VALIDATEONLY, value);
15963 break;
15964 case IDATAVALIDATE2:
15965 item_flag(ITEM_VALIDATEONLY2, value);
15966 break;
15967
15968 //Flags[5]
15969 case IDATAFLAGS:
15970 {
15971 if(unsigned(ri->idata) >= MAXITEMS)
15972 {
15973 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15974 break;
15975 }
15976 int32_t index = ri->d[rINDEX]/10000;
15977 switch(index)
15978 {
15979 case 0:
15980 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG1, value);
15981 break;
15982 case 1:
15983 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG2, value);
15984 break;
15985 case 2:
15986 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG3, value);
15987 break;
15988 case 3:
15989 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG4, value);
15990 break;
15991 case 4:
15992 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG5, value);
15993 break;
15994 case 5:
15995 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG6, value);
15996 break;
15997 case 6:
15998 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG7, value);
15999 break;
16000 case 7:
16001 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG8, value);
16002 break;
16003 case 8:
16004 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG9, value);
16005 break;
16006 case 9:
16007 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG10, value);
16008 break;
16009 case 10:
16010 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG11, value);
16011 break;
16012 case 11:
16013 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG12, value);
16014 break;
16015 case 12:
16016 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG13, value);
16017 break;
16018 case 13:
16019 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG14, value);
16020 break;
16021 case 14:
16022 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG15, value);
16023 break;
16024 case 15:
16025 SETFLAG(itemsbuf[ri->idata].flags, ITEM_PASSIVESCRIPT, value);
16026 break;
16027 }
16028
16029 break;
16030 }
16031 //Keep Old in editor
16032 case IDATAKEEPOLD:
16033 item_flag(ITEM_KEEPOLD, value);
16034 break;
16035 //Ruppes for magic
16036 case IDATARUPEECOST:
16037 item_flag(ITEM_RUPEE_MAGIC, value);
16038 break;
16039 //can be eaten
16040 case IDATAEDIBLE:
16041 item_flag(ITEM_EDIBLE, value);
16042 break;
16043 //Unused at this time
16044 case IDATAFLAGUNUSED:
16045 item_flag(ITEM_UNUSED, value);
16046 break;
16047 //gain lower level items
16048 case IDATAGAINLOWER:
16049 item_flag(ITEM_GAINOLD, value);
16050 break;
16051 //Set the action script
16052 case IDATASCRIPT:
16053 if(unsigned(ri->idata) >= MAXITEMS)
16054 {
16055 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16056 break;
16057 }
16058 FFScript::deallocateAllArrays(ScriptType::Item, ri->idata);
16059 itemsbuf[ri->idata].script=vbound(value/10000,0,255);
16060 break;
16061 case IDATASPRSCRIPT:
16062 if(unsigned(ri->idata) >= MAXITEMS)
16063 {
16064 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16065 break;
16066 }
16067 itemsbuf[ri->idata].sprite_script=vbound(value/10000,0,255);
16068 break;
16069
16070 /*
16071 case ITEMMISCD:
16072 if(0!=(s=checkItem(ri->itemref)))
16073 {
16074 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
16075 (((item*)(s))->miscellaneous[a])=value;
16076 }
16077
16078 break;*/
16079 //Attributes[10]
16080 case IDATAATTRIB: {
16081 if(unsigned(ri->idata) >= MAXITEMS)
16082 {
16083 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16084 break;
16085 }
16086 int32_t index = vbound(ri->d[rINDEX]/10000,0,9);
16087 switch(index)
16088 {
16089 case 0:
16090 itemsbuf[ri->idata].misc1=value/10000;
16091 break;
16092 case 1:
16093 itemsbuf[ri->idata].misc2=value/10000; break;
16094 case 2:
16095 itemsbuf[ri->idata].misc3=value/10000; break;
16096 case 3:
16097 itemsbuf[ri->idata].misc4=value/10000; break;
16098 case 4:
16099 itemsbuf[ri->idata].misc5=value/10000; break;
16100 case 5:
16101 itemsbuf[ri->idata].misc6=value/10000; break;
16102 case 6:
16103 itemsbuf[ri->idata].misc7=value/10000; break;
16104 case 7:
16105 itemsbuf[ri->idata].misc8=value/10000; break;
16106 case 8:
16107 itemsbuf[ri->idata].misc9=value/10000; break;
16108 case 9:
16109 itemsbuf[ri->idata].misc10=value/10000; break;
16110
16111 default:
16112 break;
16113 }
16114
16115 break;
16116 }
16117 //SpriteSprites[10]
16118 case IDATASPRITE:
16119 {
16120 if(unsigned(ri->idata) >= MAXITEMS)
16121 {
16122 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16123 break;
16124 }
16125 int32_t index = vbound(ri->d[rINDEX]/10000,0,9);
16126 switch(index)
16127 {
16128 case 0:
16129 itemsbuf[ri->idata].wpn=vbound(value/10000, 0, 255);
16130 break;
16131 case 1:
16132 itemsbuf[ri->idata].wpn2=vbound(value/10000, 0, 255); break;
16133 case 2:
16134 itemsbuf[ri->idata].wpn3=vbound(value/10000, 0, 255); break;
16135 case 3:
16136 itemsbuf[ri->idata].wpn4=vbound(value/10000, 0, 255); break;
16137 case 4:
16138 itemsbuf[ri->idata].wpn5=vbound(value/10000, 0, 255); break;
16139 case 5:
16140 itemsbuf[ri->idata].wpn6=vbound(value/10000, 0, 255); break;
16141 case 6:
16142 itemsbuf[ri->idata].wpn7=vbound(value/10000, 0, 255); break;
16143 case 7:
16144 itemsbuf[ri->idata].wpn8=vbound(value/10000, 0, 255); break;
16145 case 8:
16146 itemsbuf[ri->idata].wpn9=vbound(value/10000, 0, 255); break;
16147 case 9:
16148 itemsbuf[ri->idata].wpn10=vbound(value/10000, 0, 255); break;
16149
16150 default:
16151 break;
16152 }
16153
16154 break;
16155 }
16156 //Hero tile modifier.
16157 case IDATALTM:
16158 if(unsigned(ri->idata) >= MAXITEMS)
16159 {
16160 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16161 break;
16162 }
16163 itemsbuf[ri->idata].ltm=value/10000;
16164 break;
16165 //Pickup script
16166 case IDATAPSCRIPT:
16167 {
16168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2760 times.
2760 if(unsigned(ri->idata) >= MAXITEMS)
16169 {
16170 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16171 break;
16172 }
16173 //Need to get collect script ref, not standard idata ref!
16174
1/2
✓ Branch 0 taken 2760 times.
✗ Branch 1 not taken.
2760 const int32_t new_ref = ri->idata!=0 ? -(ri->idata) : COLLECT_SCRIPT_ITEM_ZERO;
16175 2760 FFScript::deallocateAllArrays(ScriptType::Item,new_ref);
16176 2760 itemsbuf[ri->idata].collect_script=vbound(value/10000, 0, 255);
16177 2760 break;
16178 }
16179 //pickup string
16180 case IDATAPSTRING:
16181 if(unsigned(ri->idata) >= MAXITEMS)
16182 {
16183 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16184 break;
16185 }
16186 itemsbuf[ri->idata].pstring=vbound(value/10000, 1, 255);
16187 break;
16188 case IDATAPFLAGS:
16189 if(unsigned(ri->idata) >= MAXITEMS)
16190 {
16191 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16192 break;
16193 }
16194 itemsbuf[ri->idata].pickup_string_flags=vbound(value/10000, 0, 214748);
16195 break;
16196 //magic cost
16197 case IDATAMAGCOST:
16198 if(unsigned(ri->idata) >= MAXITEMS)
16199 {
16200 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16201 break;
16202 }
16203 itemsbuf[ri->idata].cost_amount[0]=vbound(value/10000,32767,-32768);
16204 break;
16205 case IDATACOST2:
16206 if(unsigned(ri->idata) >= MAXITEMS)
16207 {
16208 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16209 break;
16210 }
16211 itemsbuf[ri->idata].cost_amount[1]=vbound(value/10000,32767,-32768);
16212 break;
16213 //cost counter ref
16214 case IDATACOSTCOUNTER:
16215 if(unsigned(ri->idata) >= MAXITEMS)
16216 {
16217 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16218 break;
16219 }
16220 itemsbuf[ri->idata].cost_counter[0]=(vbound(value/10000,-1,32));
16221 break;
16222 case IDATACOSTCOUNTER2:
16223 if(unsigned(ri->idata) >= MAXITEMS)
16224 {
16225 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16226 break;
16227 }
16228 itemsbuf[ri->idata].cost_counter[1]=(vbound(value/10000,-1,32));
16229 break;
16230 //min hearts to pick up
16231 case IDATAMINHEARTS:
16232 if(unsigned(ri->idata) >= MAXITEMS)
16233 {
16234 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16235 break;
16236 }
16237 itemsbuf[ri->idata].pickup_hearts=vbound(value/10000, 0, 214748);
16238 break;
16239 //item tile
16240 case IDATATILE:
16241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(unsigned(ri->idata) >= MAXITEMS)
16242 {
16243 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16244 break;
16245 }
16246 70 itemsbuf[ri->idata].tile=vbound(value/10000, 0, 65519);
16247 70 break;
16248 //flash
16249 case IDATAMISC:
16250 if(unsigned(ri->idata) >= MAXITEMS)
16251 {
16252 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16253 break;
16254 }
16255 itemsbuf[ri->idata].misc_flags=value/10000;
16256 break;
16257 //cset
16258 case IDATACSET:
16259 if(unsigned(ri->idata) >= MAXITEMS)
16260 {
16261 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16262 break;
16263 }
16264 itemsbuf[ri->idata].csets=vbound(value/10000,0,13);
16265 break;
16266 /*
16267 case IDATAFRAME:
16268 itemsbuf[ri->idata].frame=value/10000;
16269 break;
16270 */
16271 //A.Frames
16272 case IDATAFRAMES:
16273 if(unsigned(ri->idata) >= MAXITEMS)
16274 {
16275 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16276 break;
16277 }
16278 (itemsbuf[ri->idata].frames)=vbound(value/10000, 0, 214748);
16279 break;
16280 //A.speed
16281 case IDATAASPEED:
16282 if(unsigned(ri->idata) >= MAXITEMS)
16283 {
16284 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16285 break;
16286 }
16287 itemsbuf[ri->idata].speed=vbound(value/10000, 0, 214748);
16288 break;
16289 //Anim delay
16290 case IDATADELAY:
16291 if(unsigned(ri->idata) >= MAXITEMS)
16292 {
16293 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16294 break;
16295 }
16296 itemsbuf[ri->idata].delay=vbound(value/10000, 0, 214748);
16297 break;
16298
16299 //not one of mine.
16300 case IDATAINITDD:
16301 {
16302 int32_t a = ri->d[rINDEX] / 10000;
16303 if(unsigned(ri->idata) >= MAXITEMS)
16304 {
16305 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16306 break;
16307 }
16308
16309 if(BC::checkBounds(a, 0, 7, "itemdata->InitD") == SH::_NoError)
16310 itemsbuf[ri->idata].initiald[a] = value;
16311 }
16312 break;
16313
16314 ///----------------------------------------------------------------------------------------------------//
16315 //LWeapon Variables
16316
16317 case LWPNSCALE:
16318 if ( get_qr(qr_OLDSPRITEDRAWS) )
16319 {
16320 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
16321 "lweapon->Scale");
16322 break;
16323 }
16324 if(0!=(s=checkLWpn(ri->lwpn,"Scale")))
16325 ((weapon*)s)->scale=(zfix)(value/100.0);
16326
16327 break;
16328
16329 case LWPNX:
16330
2/2
✓ Branch 0 taken 6717 times.
✓ Branch 1 taken 187039 times.
193756 if(0!=(s=checkLWpn(ri->lwpn,"X")))
16331
2/2
✓ Branch 0 taken 61588 times.
✓ Branch 1 taken 125451 times.
187039 ((weapon*)s)->x=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
16332 193756 break;
16333
16334 case SPRITEMAXLWPN:
16335 {
16336 //No bounds check, as this is a universal function and works from NULL pointers!
16337 2 Lwpns.setMax(vbound((value/10000),1,MAX_LWPN_SPRITES));
16338 2 break;
16339 }
16340
16341 case LWPNY:
16342
2/2
✓ Branch 0 taken 6717 times.
✓ Branch 1 taken 187032 times.
193749 if(0!=(s=checkLWpn(ri->lwpn,"Y")))
16343
2/2
✓ Branch 0 taken 61588 times.
✓ Branch 1 taken 125444 times.
187032 ((weapon*)s)->y=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
16344
16345 193749 break;
16346
16347 case LWPNZ:
16348 if(0!=(s=checkLWpn(ri->lwpn,"Z")))
16349 {
16350 ((weapon*)s)->z=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
16351 if(((weapon*)s)->z < 0) ((weapon*)s)->z = zfix(0);
16352 }
16353
16354 break;
16355
16356 case LWPNJUMP:
16357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if(0!=(s=checkLWpn(ri->lwpn,"Jump")))
16358 180 ((weapon*)s)->fall=zslongToFix(value)*-100;
16359
16360 180 break;
16361
16362 case LWPNFAKEJUMP:
16363 if(0!=(s=checkLWpn(ri->lwpn,"FakeJump")))
16364 ((weapon*)s)->fakefall=zslongToFix(value)*-100;
16365
16366 break;
16367
16368 case LWPNDIR:
16369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65054 times.
65054 if(0!=(s=checkLWpn(ri->lwpn,"Dir")))
16370 {
16371 65054 ((weapon*)s)->dir=(value/10000);
16372 65054 ((weapon*)s)->doAutoRotate(true);
16373 65054 }
16374
16375 65054 break;
16376
16377 case LWPNSPECIAL:
16378 if(0!=(s=checkLWpn(ri->lwpn,"Special")))
16379 ((weapon*)s)->specialinfo=(value/10000);
16380
16381 break;
16382
16383 case LWPNGRAVITY:
16384 if(0!=(s=checkLWpn(ri->lwpn,"Gravity")))
16385 {
16386 if(value)
16387 ((weapon*)s)->moveflags |= FLAG_OBEYS_GRAV;
16388 else
16389 ((weapon*)s)->moveflags &= ~FLAG_OBEYS_GRAV;
16390 }
16391 break;
16392
16393 case LWPNSTEP:
16394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8276 times.
8276 if(0!=(s=checkLWpn(ri->lwpn,"Step")))
16395 {
16396 // fp math is bad for replay, so always ignore this QR when replay is active.
16397 // TODO: can we just delete this QR? Would it actually break anything? For now,
16398 // just disable for replay and wait for more tests to be played with this QR
16399 // ignored.
16400
3/4
✓ Branch 0 taken 7031 times.
✓ Branch 1 taken 1245 times.
✓ Branch 2 taken 7031 times.
✗ Branch 3 not taken.
8276 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
16401 {
16402 8276 ((weapon*)s)->step= zslongToFix(value / 100);
16403 8276 }
16404 else
16405 {
16406 //old, buggy code replication, round two: Go! -Z
16407 //zfix val = zslongToFix(value);
16408 //val.doFloor();
16409 //((weapon*)s)->step = ((val / 100.0).getFloat());
16410
16411 //old, buggy code replication, round THREE: Go! -Z
16412 ((weapon*)s)->step = ((value/10000)/100.0);
16413 }
16414
16415 8276 }
16416
16417 8276 break;
16418
16419 case LWPNANGLE:
16420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1469 times.
1469 if(0!=(s=checkLWpn(ri->lwpn,"Angle")))
16421 {
16422 1469 ((weapon*)s)->angle=(double)(value/10000.0);
16423 1469 ((weapon*)(s))->doAutoRotate();
16424 1469 }
16425
16426 1469 break;
16427
16428 case LWPNDEGANGLE:
16429 if(0!=(s=checkLWpn(ri->lwpn,"DegAngle")))
16430 {
16431 double rangle = (value / 10000.0) * (PI / 180.0);
16432 ((weapon*)s)->angle=(double)(rangle);
16433 ((weapon*)(s))->doAutoRotate();
16434 }
16435
16436 break;
16437
16438 case LWPNVX:
16439 if(0!=(s=checkLWpn(ri->lwpn,"Vx")))
16440 {
16441 double vy;
16442 double vx = (value / 10000.0);
16443 if (((weapon*)(s))->angular)
16444 vy = zc::math::Sin(((weapon*)s)->angle)*((weapon*)s)->step;
16445 else
16446 {
16447 switch(NORMAL_DIR(((weapon*)(s))->dir))
16448 {
16449 case l_up:
16450 case r_up:
16451 case up:
16452 vy = -1.0*((weapon*)s)->step;
16453 break;
16454 case l_down:
16455 case r_down:
16456 case down:
16457 vy = ((weapon*)s)->step;
16458 break;
16459
16460 default:
16461 vy = 0;
16462 break;
16463 }
16464 }
16465 ((weapon*)s)->angular = true;
16466 ((weapon*)s)->angle=atan2(vy, vx);
16467 ((weapon*)s)->step=FFCore.Distance(0, 0, vx, vy)/10000.0;
16468 ((weapon*)(s))->doAutoRotate();
16469 }
16470
16471 break;
16472
16473 case LWPNVY:
16474 if(0!=(s=checkLWpn(ri->lwpn,"Vy")))
16475 {
16476 double vx;
16477 double vy = (value / 10000.0);
16478 if (((weapon*)(s))->angular)
16479 vx = zc::math::Cos(((weapon*)s)->angle)*((weapon*)s)->step;
16480 else
16481 {
16482 switch(NORMAL_DIR(((weapon*)(s))->dir))
16483 {
16484 case l_up:
16485 case l_down:
16486 case left:
16487 vx = -1.0*((weapon*)s)->step;
16488 break;
16489 case r_down:
16490 case r_up:
16491 case right:
16492 vx = ((weapon*)s)->step;
16493 break;
16494
16495 default:
16496 vx = 0;
16497 break;
16498 }
16499 }
16500 ((weapon*)s)->angular = true;
16501 ((weapon*)s)->angle=atan2(vy, vx);
16502 ((weapon*)s)->step=FFCore.Distance(0, 0, vx, vy)/10000.0;
16503 ((weapon*)(s))->doAutoRotate();
16504 }
16505
16506 break;
16507
16508 case LWPNANGULAR:
16509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1175 times.
1175 if(0!=(s=checkLWpn(ri->lwpn,"Angular")))
16510 {
16511 1175 ((weapon*)s)->angular=(value!=0);
16512 1175 ((weapon*)(s))->doAutoRotate(false, true);
16513 1175 }
16514
16515 1175 break;
16516
16517 case LWPNAUTOROTATE:
16518 if(0!=(s=checkLWpn(ri->lwpn,"AutoRotate")))
16519 {
16520 ((weapon*)s)->autorotate=(value!=0);
16521 ((weapon*)(s))->doAutoRotate(false, true);
16522 }
16523
16524 break;
16525
16526 case LWPNBEHIND:
16527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(0!=(s=checkLWpn(ri->lwpn,"Behind")))
16528 16 ((weapon*)s)->behind=(value!=0);
16529
16530 16 break;
16531
16532 case LWPNDRAWTYPE:
16533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 if(0!=(s=checkLWpn(ri->lwpn,"DrawStyle")))
16534 49 ((weapon*)s)->drawstyle=(value/10000);
16535
16536 49 break;
16537
16538 case LWPNPOWER:
16539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69347 times.
69347 if(0!=(s=checkLWpn(ri->lwpn,"Damage")))
16540 69347 ((weapon*)s)->power=(value/10000);
16541
16542 69347 break;
16543 /*
16544 case LWPNRANGE:
16545 if(0!=(s=checkLWpn(ri->lwpn,"Range")))
16546 ((weapon*)s)->scriptrange=vbound((value/10000),0,512); //Allow it to move off-screen. -Z
16547 break;
16548 */
16549 case LWPNDEAD:
16550
2/2
✓ Branch 0 taken 6717 times.
✓ Branch 1 taken 132457 times.
139174 if(0!=(s=checkLWpn(ri->lwpn,"DeadState")))
16551 {
16552 132457 auto dead = value/10000;
16553 132457 ((weapon*)s)->dead=dead;
16554
2/2
✓ Branch 0 taken 68348 times.
✓ Branch 1 taken 64109 times.
132457 if(dead != 0) ((weapon*)s)->weapon_dying_frame = false;
16555 132457 }
16556 139174 break;
16557
16558 case LWPNID:
16559 if(0!=(s=checkLWpn(ri->lwpn,"ID")))
16560 ((weapon*)s)->id=(value/10000);
16561
16562 break;
16563
16564 case LWPNTILE:
16565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1853 times.
1853 if(0!=(s=checkLWpn(ri->lwpn,"Tile")))
16566 1853 ((weapon*)s)->tile=(value/10000);
16567
16568 1853 break;
16569
16570 case LWPNSCRIPTTILE:
16571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3221 times.
3221 if(0!=(s=checkLWpn(ri->lwpn,"ScriptTile")))
16572 3221 ((weapon*)s)->scripttile=vbound((value/10000),-1,NEWMAXTILES-1);
16573
16574 3221 break;
16575
16576 case LWPNSCRIPTFLIP:
16577 if(0!=(s=checkLWpn(ri->lwpn,"ScriptFlip")))
16578 ((weapon*)s)->scriptflip=vbound((value/10000),-1,127);
16579
16580 break;
16581
16582 case LWPNCSET:
16583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2065 times.
2065 if(0!=(s=checkLWpn(ri->lwpn,"CSet")))
16584 2065 ((weapon*)s)->cs=(value/10000)&15;
16585
16586 2065 break;
16587
16588 case LWPNFLASHCSET:
16589 if(0!=(s=checkLWpn(ri->lwpn,"FlashCSet")))
16590 (((weapon*)s)->o_cset)|=(value/10000)<<4;
16591
16592 break;
16593
16594 case LWPNFRAMES:
16595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 404 times.
404 if(0!=(s=checkLWpn(ri->lwpn,"NumFrames")))
16596 404 ((weapon*)s)->frames=(value/10000);
16597
16598 404 break;
16599
16600 case LWPNFRAME:
16601 if(0!=(s=checkLWpn(ri->lwpn,"Frame")))
16602 ((weapon*)s)->aframe=(value/10000);
16603
16604 break;
16605
16606 case LWPNASPEED:
16607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(0!=(s=checkLWpn(ri->lwpn,"ASpeed")))
16608 457 ((weapon*)s)->o_speed=(value/10000);
16609
16610 457 break;
16611
16612 case LWPNFLASH:
16613 if(0!=(s=checkLWpn(ri->lwpn,"Flash")))
16614 ((weapon*)s)->flash=(value/10000);
16615
16616 break;
16617
16618 case LWPNFLIP:
16619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 683 times.
683 if(0!=(s=checkLWpn(ri->lwpn,"Flip")))
16620 683 ((weapon*)s)->flip=(value/10000);
16621
16622 683 break;
16623
16624 case LWPNROTATION:
16625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4922 times.
4922 if ( get_qr(qr_OLDSPRITEDRAWS) )
16626 {
16627 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
16628 "lweapon->Rotation");
16629 break;
16630 }
16631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4922 times.
4922 if(0!=(s=checkLWpn(ri->lwpn,"Rotation")))
16632 4922 ((weapon*)s)->rotation=(value/10000);
16633
16634 4922 break;
16635
16636 case LWPNEXTEND:
16637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(0!=(s=checkLWpn(ri->lwpn,"Extend")))
16638 16 ((weapon*)s)->extend=(value/10000);
16639
16640 16 break;
16641
16642 case LWPNOTILE:
16643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1841 times.
1841 if(0!=(s=checkLWpn(ri->lwpn,"OriginalTile")))
16644 {
16645 //zprint("LWPNOTILE before write: %d\n", ((weapon*)s)->o_tile);
16646 1841 ((weapon*)s)->o_tile=(value/10000);
16647 1841 ((weapon*)s)->ref_o_tile=(value/10000);
16648 //((weapon*)s)->script_wrote_otile=1; //Removing this as of 26th October, 2019 -Z
16649 //if at some future point we WANT writing ->Tile to also overwrite ->OriginalTile,
16650 //then either the user will need to manually write tile, or we can add a QR and
16651 // write ->tile here. 'script_wrote_otile' is out.
16652 //zprint("LWPNOTILE after write: %d\n", ((weapon*)s)->o_tile);
16653 1841 }
16654 1841 break;
16655
16656 case LWPNOCSET:
16657 if(0!=(s=checkLWpn(ri->lwpn,"OriginalCSet")))
16658 (((weapon*)s)->o_cset)|=(value/10000)&15;
16659
16660 break;
16661
16662 case LWPNHXOFS:
16663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60616 times.
60616 if(0!=(s=checkLWpn(ri->lwpn,"HitXOffset")))
16664 60616 (((weapon*)s)->hxofs)=(value/10000);
16665
16666 60616 break;
16667
16668 case LWPNHYOFS:
16669
1/2
✓ Branch 0 taken 60616 times.
✗ Branch 1 not taken.
60616 if(0!=(s=checkLWpn(ri->lwpn,"HitYOffset")))
16670 60616 (((weapon*)s)->hyofs)=(value/10000);
16671
16672 60616 break;
16673
16674 case LWPNXOFS:
16675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
156 if(0!=(s=checkLWpn(ri->lwpn,"DrawXOffset")))
16676 156 (((weapon*)s)->xofs)=(zfix)(value/10000);
16677
16678 156 break;
16679
16680 case LWPNYOFS:
16681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63470 times.
63470 if(0!=(s=checkLWpn(ri->lwpn,"DrawYOffset")))
16682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63470 times.
63470 (((weapon*)s)->yofs)=(zfix)(value/10000)+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16683
16684 63470 break;
16685
16686 case LWPNSHADOWXOFS:
16687 if(0!=(s=checkLWpn(ri->lwpn,"ShadowXOffset")))
16688 (((weapon*)s)->shadowxofs)=(zfix)(value/10000);
16689
16690 break;
16691
16692 case LWPNSHADOWYOFS:
16693 if(0!=(s=checkLWpn(ri->lwpn,"ShadowYOffset")))
16694 (((weapon*)s)->shadowyofs)=(zfix)(value/10000);
16695
16696 break;
16697
16698 case LWPNTOTALDYOFFS:
16699 break; //READ-ONLY
16700
16701 case LWPNZOFS:
16702 if(0!=(s=checkLWpn(ri->lwpn,"DrawZOffset")))
16703 (((weapon*)s)->zofs)=(zfix)(value/10000);
16704
16705 break;
16706
16707 case LWPNHXSZ:
16708
1/2
✓ Branch 0 taken 61740 times.
✗ Branch 1 not taken.
61740 if(0!=(s=checkLWpn(ri->lwpn,"HitWidth")))
16709 61740 (((weapon*)s)->hit_width)=(value/10000);
16710
16711 61740 break;
16712
16713 case LWPNHYSZ:
16714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61757 times.
61757 if(0!=(s=checkLWpn(ri->lwpn,"HitHeight")))
16715 61757 (((weapon*)s)->hit_height)=(value/10000);
16716
16717 61757 break;
16718
16719 case LWPNHZSZ:
16720 if(0!=(s=checkLWpn(ri->lwpn,"HitZHeight")))
16721 (((weapon*)s)->hzsz)=(value/10000);
16722
16723 break;
16724
16725 case LWPNTXSZ:
16726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(0!=(s=checkLWpn(ri->lwpn,"TileWidth")))
16727 10 (((weapon*)s)->txsz)=vbound((value/10000),1,20);
16728
16729 10 break;
16730
16731 case LWPNTYSZ:
16732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(0!=(s=checkLWpn(ri->lwpn,"TileHeight")))
16733 10 (((weapon*)s)->tysz)=vbound((value/10000),1,20);
16734
16735 10 break;
16736
16737 case LWPNMISCD:
16738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 497624 times.
497624 if(0!=(s=checkLWpn(ri->lwpn,"Misc")))
16739 {
16740 497624 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
16741 497624 (((weapon*)(s))->miscellaneous[a])=value;
16742 497624 }
16743
16744 497624 break;
16745
16746 case LWPNCOLLDET:
16747
1/2
✓ Branch 0 taken 16120 times.
✗ Branch 1 not taken.
16120 if(0!=(s=checkLWpn(ri->lwpn,"CollDetection")))
16748 16120 (((weapon*)(s))->scriptcoldet)=value/10000;
16749
16750 16120 break;
16751
16752 case LWPNENGINEANIMATE:
16753 if(0!=(s=checkLWpn(ri->lwpn,"Animation")))
16754 (((weapon*)(s))->do_animation)=(value ? 1 : 0);
16755
16756 break;
16757
16758 case LWPNPARENT:
16759 {
16760 //int32_t pitm = (vbound(value/10000,1,(MAXITEMS-1)));
16761 //zprint("Attempting to set ParentItem to: %d\n", pitm);
16762
16763 if(0!=(s=checkLWpn(ri->lwpn,"Parent")))
16764 (((weapon*)(s))->parentitem)=(vbound(value/10000,-1,(MAXITEMS-1)));
16765 break;
16766 }
16767
16768 case LWPNLEVEL:
16769 if(0!=(s=checkLWpn(ri->lwpn,"Level")))
16770 (((weapon*)(s))->type)=value/10000;
16771
16772 break;
16773
16774 case LWPNSCRIPT:
16775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60902 times.
60902 if(0!=(s=checkLWpn(ri->lwpn,"Script")))
16776 {
16777 60902 FFScript::deallocateAllArrays(ScriptType::Lwpn, ri->lwpn);
16778 60902 (((weapon*)(s))->weaponscript)=vbound(value/10000,0,NUMSCRIPTWEAPONS-1);
16779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60902 times.
60902 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
16780 {
16781
2/2
✓ Branch 0 taken 487216 times.
✓ Branch 1 taken 60902 times.
548118 for(int32_t q=0; q<8; q++)
16782 487216 (((weapon*)(s))->weap_initd[q]) = 0;
16783 60902 }
16784 60902 }
16785 60902 break;
16786
16787 case LWPNUSEWEAPON:
16788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 603 times.
603 if(0!=(s=checkLWpn(ri->lwpn,"Weapon")))
16789 603 (((weapon*)(s))->useweapon)=vbound(value/10000,0,255);
16790
16791 603 break;
16792
16793 case LWPNUSEDEFENCE:
16794 if(0!=(s=checkLWpn(ri->lwpn,"Defense")))
16795 (((weapon*)(s))->usedefence)=vbound(value/10000,0,255);
16796
16797 break;
16798
16799 case LWPNINITD:
16800 {
16801 238 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
16802
1/2
✓ Branch 0 taken 238 times.
✗ Branch 1 not taken.
238 if(0!=(s=checkLWpn(ri->lwpn,"InitD[]")))
16803 {
16804 238 (((weapon*)(s))->weap_initd[a])=value;
16805 238 }
16806 238 break;
16807 }
16808 case LWPNFALLCLK:
16809 if(0!=(s=checkLWpn(ri->lwpn,"Falling")))
16810 {
16811 if(((weapon*)(s))->fallclk != 0 && value == 0)
16812 {
16813 ((weapon*)(s))->cs = ((weapon*)(s))->old_cset;
16814 ((weapon*)(s))->tile = ((weapon*)(s))->o_tile;
16815 }
16816 else if(((weapon*)(s))->fallclk == 0 && value != 0) ((weapon*)(s))->old_cset = ((weapon*)(s))->cs;
16817 ((weapon*)(s))->fallclk = vbound(value/10000,0,70);
16818 }
16819 break;
16820 case LWPNFALLCMB:
16821 if(0!=(s=checkLWpn(ri->lwpn,"FallCombo")))
16822 {
16823 ((weapon*)(s))->fallCombo = vbound(value/10000,0,MAXCOMBOS-1);
16824 }
16825 break;
16826 case LWPNDROWNCLK:
16827 if(0!=(s=checkLWpn(ri->lwpn,"Drowning")))
16828 {
16829 if(((weapon*)(s))->drownclk != 0 && value == 0)
16830 {
16831 ((weapon*)(s))->cs = ((weapon*)(s))->old_cset;
16832 ((weapon*)(s))->tile = ((weapon*)(s))->o_tile;
16833 }
16834 else if(((weapon*)(s))->drownclk == 0 && value != 0) ((weapon*)(s))->old_cset = ((weapon*)(s))->cs;
16835 ((weapon*)(s))->drownclk = vbound(value/10000,0,70);
16836 }
16837 break;
16838 case LWPNDROWNCMB:
16839 if(0!=(s=checkLWpn(ri->lwpn,"DrownCombo")))
16840 {
16841 ((weapon*)(s))->drownCombo = vbound(value/10000,0,MAXCOMBOS-1);
16842 }
16843 break;
16844 case LWPNFAKEZ:
16845 if(0!=(s=checkLWpn(ri->lwpn,"FakeZ")))
16846 {
16847 ((weapon*)s)->fakez=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
16848 if(((weapon*)s)->fakez < 0) ((weapon*)s)->fakez = zfix(0);
16849 }
16850
16851 break;
16852
16853 case LWPNMOVEFLAGS:
16854 {
16855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 265 times.
265 if(0!=(s=checkLWpn(ri->lwpn,"MoveFlags[]")))
16856 {
16857 265 int32_t indx = ri->d[rINDEX]/10000;
16858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 265 times.
265 if(BC::checkBounds(indx, 0, 10, "lweapon->MoveFlags[]") == SH::_NoError)
16859 {
16860 //All bits, in order, of a single byte; just use bitwise
16861 265 int32_t bit = 1<<indx;
16862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 265 times.
265 if(value)
16863 ((weapon*)(s))->moveflags |= bit;
16864 else
16865 265 ((weapon*)(s))->moveflags &= ~bit;
16866 265 }
16867 265 }
16868 265 break;
16869 }
16870 case LWPNFLAGS:
16871 {
16872 if(0!=(s=checkLWpn(ri->lwpn,"Flags[]")))
16873 {
16874 int32_t indx = ri->d[rINDEX]/10000;
16875 if(BC::checkBounds(indx, 0, WFLAG_MAX, "lweapon->Flags[]") == SH::_NoError)
16876 {
16877 //All bits, in order, of a single byte; just use bitwise
16878 int32_t bit = 1<<indx;
16879 if(value)
16880 ((weapon*)(s))->misc_wflags |= bit;
16881 else
16882 ((weapon*)(s))->misc_wflags &= ~bit;
16883 }
16884 }
16885 break;
16886 }
16887
16888 case LWPNGLOWRAD:
16889 if(0!=(s=checkLWpn(ri->lwpn,"LightRadius")))
16890 {
16891 ((weapon*)(s))->glowRad = vbound(value/10000,0,255);
16892 }
16893 break;
16894
16895 case LWPNGLOWSHP:
16896 if(0!=(s=checkLWpn(ri->lwpn,"LightShape")))
16897 {
16898 ((weapon*)(s))->glowShape = vbound(value/10000,0,255);
16899 }
16900 break;
16901
16902 case LWPNUNBL:
16903 if(0!=(s=checkLWpn(ri->lwpn,"Unblockable")))
16904 {
16905 ((weapon*)(s))->unblockable = (value/10000)&WPNUNB_ALL;
16906 }
16907 break;
16908
16909 case LWPNSHADOWSPR:
16910 if(0!=(s=checkLWpn(ri->lwpn,"ShadowSprite")))
16911 {
16912 ((weapon*)(s))->spr_shadow = vbound(value/10000, 0, 255);
16913 }
16914 break;
16915 case LWSWHOOKED:
16916 break; //read-only
16917 case LWPNTIMEOUT:
16918 if(0!=(s=checkLWpn(ri->lwpn,"Timeout")))
16919 {
16920 ((weapon*)(s))->weap_timeout = vbound(value/10000,0,214748);
16921 }
16922 break;
16923 case LWPNDEATHITEM:
16924 if(0!=(s=checkLWpn(ri->lwpn,"DeathItem")))
16925 {
16926 ((weapon*)(s))->death_spawnitem = vbound(value/10000,-1,MAXITEMS-1);
16927 }
16928 break;
16929 case LWPNDEATHDROPSET:
16930 if(0!=(s=checkLWpn(ri->lwpn,"DeathDropset")))
16931 {
16932 ((weapon*)(s))->death_spawndropset = vbound(value/10000,-1,MAXITEMDROPSETS-1);
16933 }
16934 break;
16935 case LWPNDEATHIPICKUP:
16936 if(0!=(s=checkLWpn(ri->lwpn,"DeathItemPFlags")))
16937 {
16938 ((weapon*)(s))->death_item_pflags = value/10000;
16939 }
16940 break;
16941 case LWPNDEATHSPRITE:
16942 if(0!=(s=checkLWpn(ri->lwpn,"DeathSprite")))
16943 {
16944 ((weapon*)(s))->death_sprite = vbound(value/10000,-255,MAXWPNS-1);
16945 }
16946 break;
16947 case LWPNDEATHSFX:
16948 if(0!=(s=checkLWpn(ri->lwpn,"DeathSFX")))
16949 {
16950 ((weapon*)(s))->death_sfx = vbound(value/10000,0,WAV_COUNT);
16951 }
16952 break;
16953 case LWPNLIFTLEVEL:
16954 if(0!=(s=checkLWpn(ri->lwpn,"LiftLevel")))
16955 {
16956 ((weapon*)(s))->lift_level = vbound(value/10000,0,255);
16957 }
16958 break;
16959 case LWPNLIFTTIME:
16960 if(0!=(s=checkLWpn(ri->lwpn,"LiftTime")))
16961 {
16962 ((weapon*)(s))->lift_time = vbound(value/10000,0,255);
16963 }
16964 break;
16965 case LWPNLIFTHEIGHT:
16966 if(0!=(s=checkLWpn(ri->lwpn,"LiftHeight")))
16967 {
16968 ((weapon*)(s))->lift_height = zslongToFix(value);
16969 }
16970 break;
16971
16972 ///----------------------------------------------------------------------------------------------------//
16973 //EWeapon Variables
16974 case EWPNSCALE:
16975 if ( get_qr(qr_OLDSPRITEDRAWS) )
16976 {
16977 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
16978 "eweapon->Scale");
16979 break;
16980 }
16981 if(0!=(s=checkEWpn(ri->ewpn,"Scale")))
16982 ((weapon*)s)->scale=(zfix)(value/100.0);
16983
16984 break;
16985
16986 case EWPNX:
16987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226569 times.
226569 if(0!=(s=checkEWpn(ri->ewpn,"X")))
16988
2/2
✓ Branch 0 taken 7282 times.
✓ Branch 1 taken 219287 times.
226569 ((weapon*)s)->x = (get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
16989
16990 226569 break;
16991
16992 case SPRITEMAXEWPN:
16993 {
16994 //No bounds check, as this is a universal function and works from NULL pointers!
16995 2 Ewpns.setMax(vbound((value/10000),1,MAX_EWPN_SPRITES));
16996 2 break;
16997 }
16998
16999 case EWPNY:
17000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226856 times.
226856 if(0!=(s=checkEWpn(ri->ewpn,"Y")))
17001
2/2
✓ Branch 0 taken 7170 times.
✓ Branch 1 taken 219686 times.
226856 ((weapon*)s)->y = (get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
17002
17003 226856 break;
17004
17005 case EWPNZ:
17006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6823 times.
6823 if(0!=(s=checkEWpn(ri->ewpn,"Z")))
17007 {
17008
2/2
✓ Branch 0 taken 1203 times.
✓ Branch 1 taken 5620 times.
6823 ((weapon*)s)->z=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
17009
1/2
✓ Branch 0 taken 6823 times.
✗ Branch 1 not taken.
6823 if(((weapon*)s)->z < 0) ((weapon*)s)->z = zfix(0);
17010 6823 }
17011
17012 6823 break;
17013
17014 case EWPNJUMP:
17015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6048 times.
6048 if(0!=(s=checkEWpn(ri->ewpn,"Jump")))
17016 6048 ((weapon*)s)->fall=zslongToFix(value)*-100;
17017
17018 6048 break;
17019
17020 case EWPNFAKEJUMP:
17021 if(0!=(s=checkEWpn(ri->ewpn,"FakeJump")))
17022 ((weapon*)s)->fakefall=zslongToFix(value)*-100;
17023
17024 break;
17025
17026 case EWPNDIR:
17027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138270 times.
138270 if(0!=(s=checkEWpn(ri->ewpn,"Dir")))
17028 {
17029 138270 ((weapon*)s)->dir=(value/10000);
17030 138270 ((weapon*)s)->doAutoRotate(true);
17031 138270 }
17032
17033 138270 break;
17034
17035 case EWPNLEVEL:
17036 if(0!=(s=checkEWpn(ri->ewpn,"Level")))
17037 ((weapon*)s)->type=(value/10000);
17038
17039 break;
17040
17041 case EWPNGRAVITY:
17042 if(0!=(s=checkEWpn(ri->ewpn,"Gravity")))
17043 {
17044 if(value)
17045 ((weapon*)s)->moveflags |= FLAG_OBEYS_GRAV;
17046 else
17047 ((weapon*)s)->moveflags &= ~FLAG_OBEYS_GRAV;
17048 }
17049 break;
17050
17051 case EWPNSTEP:
17052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264908 times.
264908 if(0!=(s=checkEWpn(ri->ewpn,"Step")))
17053 {
17054
3/4
✓ Branch 0 taken 243133 times.
✓ Branch 1 taken 21775 times.
✓ Branch 2 taken 243133 times.
✗ Branch 3 not taken.
264908 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
17055 {
17056 264908 ((weapon*)s)->step= zslongToFix(value / 100);
17057 264908 }
17058 else
17059 {
17060 //old, buggy code replication, round two: Go! -Z
17061 //zfix val = zslongToFix(value);
17062 //val.doFloor();
17063 //((weapon*)s)->step = ((val / 100.0).getFloat());
17064
17065 //old, buggy code replication, round THREE: Go! -Z
17066 ((weapon*)s)->step = ((value/10000)/100.0);
17067 //zprint2("ewpn step is %d\n", ((weapon*)s)->step);
17068 }
17069 264908 }
17070
17071 264908 break;
17072
17073 case EWPNANGLE:
17074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134925 times.
134925 if(0!=(s=checkEWpn(ri->ewpn,"Angle")))
17075 {
17076 134925 ((weapon*)s)->angle=(double)(value/10000.0);
17077 134925 ((weapon*)(s))->doAutoRotate();
17078 134925 }
17079
17080 134925 break;
17081
17082 case EWPNDEGANGLE:
17083 if(0!=(s=checkEWpn(ri->ewpn,"DegAngle")))
17084 {
17085 double rangle = (value / 10000.0) * (PI / 180.0);
17086 ((weapon*)s)->angle=(double)(rangle);
17087 ((weapon*)(s))->doAutoRotate();
17088 }
17089
17090 break;
17091
17092 case EWPNVX:
17093 if(0!=(s=checkEWpn(ri->ewpn,"Vx")))
17094 {
17095 double vy;
17096 double vx = (value / 10000.0);
17097 if (((weapon*)(s))->angular)
17098 vy = zc::math::Sin(((weapon*)s)->angle)*((weapon*)s)->step;
17099 else
17100 {
17101 switch(NORMAL_DIR(((weapon*)(s))->dir))
17102 {
17103 case l_up:
17104 case r_up:
17105 case up:
17106 vy = -1.0*((weapon*)s)->step;
17107 break;
17108 case l_down:
17109 case r_down:
17110 case down:
17111 vy = ((weapon*)s)->step;
17112 break;
17113
17114 default:
17115 vy = 0;
17116 break;
17117 }
17118 }
17119 ((weapon*)s)->angular = true;
17120 ((weapon*)s)->angle=atan2(vy, vx);
17121 ((weapon*)s)->step=FFCore.Distance(0, 0, vx, vy)/10000;
17122 ((weapon*)(s))->doAutoRotate();
17123 }
17124
17125 break;
17126
17127 case EWPNVY:
17128 if(0!=(s=checkEWpn(ri->ewpn,"Vy")))
17129 {
17130 double vx;
17131 double vy = (value / 10000.0);
17132 if (((weapon*)(s))->angular)
17133 vx = zc::math::Cos(((weapon*)s)->angle)*((weapon*)s)->step;
17134 else
17135 {
17136 switch(NORMAL_DIR(((weapon*)(s))->dir))
17137 {
17138 case l_up:
17139 case l_down:
17140 case left:
17141 vx = -1.0*((weapon*)s)->step;
17142 break;
17143 case r_down:
17144 case r_up:
17145 case right:
17146 vx = ((weapon*)s)->step;
17147 break;
17148
17149 default:
17150 vx = 0;
17151 break;
17152 }
17153 }
17154 ((weapon*)s)->angular = true;
17155 ((weapon*)s)->angle=atan2(vy, vx);
17156 ((weapon*)s)->step=FFCore.Distance(0, 0, vx, vy)/10000;
17157 ((weapon*)(s))->doAutoRotate();
17158 }
17159
17160 break;
17161
17162 case EWPNANGULAR:
17163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131702 times.
131702 if(0!=(s=checkEWpn(ri->ewpn,"Angular")))
17164 {
17165 131702 ((weapon*)s)->angular=(value!=0);
17166 131702 ((weapon*)(s))->doAutoRotate(false, true);
17167 131702 }
17168
17169 131702 break;
17170
17171 case EWPNAUTOROTATE:
17172 if(0!=(s=checkEWpn(ri->ewpn,"AutoRotate")))
17173 {
17174 ((weapon*)s)->autorotate=(value!=0);
17175 ((weapon*)(s))->doAutoRotate(false, true);
17176 }
17177
17178 break;
17179
17180 case EWPNBEHIND:
17181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(0!=(s=checkEWpn(ri->ewpn,"Behind")))
17182 47 ((weapon*)s)->behind=(value!=0);
17183
17184 47 break;
17185
17186 case EWPNDRAWTYPE:
17187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12175 times.
12175 if(0!=(s=checkEWpn(ri->ewpn,"DrawStyle")))
17188 12175 ((weapon*)s)->drawstyle=(value/10000);
17189
17190 12175 break;
17191
17192 case EWPNPOWER:
17193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132679 times.
132679 if(0!=(s=checkEWpn(ri->ewpn,"Damage")))
17194 132679 ((weapon*)s)->power=(value/10000);
17195
17196 132679 break;
17197
17198 case EWPNDEAD:
17199
1/2
✓ Branch 0 taken 23997 times.
✗ Branch 1 not taken.
23997 if(0!=(s=checkEWpn(ri->ewpn,"DeadState")))
17200 {
17201 23997 auto dead = value/10000;
17202 23997 ((weapon*)s)->dead=dead;
17203
2/2
✓ Branch 0 taken 15476 times.
✓ Branch 1 taken 8521 times.
23997 if(dead != 0) ((weapon*)s)->weapon_dying_frame = false;
17204 23997 }
17205
17206 23997 break;
17207
17208 case EWPNID:
17209 if(0!=(s=checkEWpn(ri->ewpn,"ID")))
17210 ((weapon*)s)->id=(value/10000);
17211
17212 break;
17213
17214 case EWPNTILE:
17215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9747 times.
9747 if(0!=(s=checkEWpn(ri->ewpn,"Tile")))
17216 9747 ((weapon*)s)->tile=(value/10000);
17217
17218 9747 break;
17219
17220 case EWPNSCRIPTTILE:
17221 if(0!=(s=checkEWpn(ri->ewpn,"ScriptTile")))
17222 ((weapon*)s)->scripttile=vbound((value/10000),-1, NEWMAXTILES-1);
17223
17224 break;
17225
17226 case EWPNSCRIPTFLIP:
17227 if(0!=(s=checkEWpn(ri->ewpn,"ScriptFlip")))
17228 ((weapon*)s)->scriptflip=vbound((value/10000),-1, 127);
17229
17230 break;
17231
17232 case EWPNCSET:
17233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2072 times.
2072 if(0!=(s=checkEWpn(ri->ewpn,"CSet")))
17234 2072 ((weapon*)s)->cs=(value/10000)&15;
17235
17236 2072 break;
17237
17238 case EWPNFLASHCSET:
17239 if(0!=(s=checkEWpn(ri->ewpn,"FlashCSet")))
17240 (((weapon*)s)->o_cset)|=(value/10000)<<4;
17241
17242 break;
17243
17244 case EWPNFRAMES:
17245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 if(0!=(s=checkEWpn(ri->ewpn,"NumFrames")))
17246 41 ((weapon*)s)->frames=(value/10000);
17247
17248 41 break;
17249
17250 case EWPNFRAME:
17251 if(0!=(s=checkEWpn(ri->ewpn,"Frame")))
17252 ((weapon*)s)->aframe=(value/10000);
17253
17254 break;
17255
17256 case EWPNASPEED:
17257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 if(0!=(s=checkEWpn(ri->ewpn,"ASpeed")))
17258 41 ((weapon*)s)->o_speed=(value/10000);
17259
17260 41 break;
17261
17262 case EWPNFLASH:
17263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
549 if(0!=(s=checkEWpn(ri->ewpn,"Flash")))
17264 549 ((weapon*)s)->flash=(value/10000);
17265
17266 549 break;
17267
17268 case EWPNFLIP:
17269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49622 times.
49622 if(0!=(s=checkEWpn(ri->ewpn,"Flip")))
17270 49622 ((weapon*)s)->flip=(value/10000);
17271
17272 49622 break;
17273
17274 case EWPNROTATION:
17275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1104 times.
1104 if ( get_qr(qr_OLDSPRITEDRAWS) )
17276 {
17277 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
17278 "eweapon->Rotation");
17279 break;
17280 }
17281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1104 times.
1104 if(0!=(s=checkEWpn(ri->ewpn,"Rotation")))
17282 1104 ((weapon*)s)->rotation=(value/10000);
17283
17284 1104 break;
17285
17286 case EWPNEXTEND:
17287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111461 times.
111461 if(0!=(s=checkEWpn(ri->ewpn,"Extend")))
17288 111461 ((weapon*)s)->extend=(value/10000);
17289
17290 111461 break;
17291
17292 case EWPNOTILE:
17293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4552 times.
4552 if(0!=(s=checkEWpn(ri->ewpn,"OriginalTile")))
17294 {
17295 4552 ((weapon*)s)->o_tile=(value/10000);
17296 4552 ((weapon*)s)->ref_o_tile=(value/10000);
17297 4552 }
17298
17299 4552 break;
17300
17301 case EWPNOCSET:
17302 if(0!=(s=checkEWpn(ri->ewpn,"OriginalCSet")))
17303 (((weapon*)s)->o_cset)|=(value/10000)&15;
17304
17305 break;
17306
17307 case EWPNHXOFS:
17308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138269 times.
138269 if(0!=(s=checkEWpn(ri->ewpn,"HitXOffset")))
17309 138269 (((weapon*)s)->hxofs)=(value/10000);
17310
17311 138269 break;
17312
17313 case EWPNHYOFS:
17314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137776 times.
137776 if(0!=(s=checkEWpn(ri->ewpn,"HitYOffset")))
17315 137776 (((weapon*)s)->hyofs)=(value/10000);
17316
17317 137776 break;
17318
17319 case EWPNXOFS:
17320
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 35366 times.
35370 if(0!=(s=checkEWpn(ri->ewpn,"DrawXOffset")))
17321 35366 (((weapon*)s)->xofs)=(zfix)(value/10000);
17322
17323 35370 break;
17324
17325 case EWPNYOFS:
17326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38448 times.
38448 if(0!=(s=checkEWpn(ri->ewpn,"DrawYOffset")))
17327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38448 times.
38448 (((weapon*)s)->yofs)=(zfix)(value/10000)+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17328
17329 38448 break;
17330 case EWPNTOTALDYOFFS:
17331 break; //READ-ONLY
17332
17333 case EWPNSHADOWXOFS:
17334 if(0!=(s=checkEWpn(ri->ewpn,"ShadowXOffset")))
17335 (((weapon*)s)->shadowxofs)=(zfix)(value/10000);
17336
17337 break;
17338
17339 case EWPNSHADOWYOFS:
17340 if(0!=(s=checkEWpn(ri->ewpn,"ShadowYOffset")))
17341 (((weapon*)s)->shadowyofs)=(zfix)(value/10000);
17342
17343 break;
17344
17345 case EWPNZOFS:
17346 if(0!=(s=checkEWpn(ri->ewpn,"DrawZOffset")))
17347 (((weapon*)s)->zofs)=(zfix)(value/10000);
17348
17349 break;
17350
17351 case EWPNHXSZ:
17352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 234661 times.
234661 if(0!=(s=checkEWpn(ri->ewpn,"HitWidth")))
17353 234661 (((weapon*)s)->hit_width)=(value/10000);
17354
17355 234661 break;
17356
17357 case EWPNHYSZ:
17358
1/2
✓ Branch 0 taken 234074 times.
✗ Branch 1 not taken.
234074 if(0!=(s=checkEWpn(ri->ewpn,"HitHeight")))
17359 234074 (((weapon*)s)->hit_height)=(value/10000);
17360
17361 234074 break;
17362
17363 case EWPNHZSZ:
17364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(0!=(s=checkEWpn(ri->ewpn,"HitZHeight")))
17365 44 (((weapon*)s)->hzsz)=(value/10000);
17366
17367 44 break;
17368
17369 case EWPNTXSZ:
17370
1/2
✓ Branch 0 taken 111461 times.
✗ Branch 1 not taken.
111461 if(0!=(s=checkEWpn(ri->ewpn,"TileWidth")))
17371 111461 (((weapon*)s)->txsz)=vbound((value/10000),1,20);
17372
17373 111461 break;
17374
17375 case EWPNTYSZ:
17376
1/2
✓ Branch 0 taken 111461 times.
✗ Branch 1 not taken.
111461 if(0!=(s=checkEWpn(ri->ewpn,"TileHeight")))
17377 111461 (((weapon*)s)->tysz)=vbound((value/10000),1,20);
17378
17379 111461 break;
17380
17381 case EWPNMISCD:
17382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 910117 times.
910117 if(0!=(s=checkEWpn(ri->ewpn,"Misc")))
17383 {
17384 910117 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
17385 910117 (((weapon*)(s))->miscellaneous[a])=value;
17386 910117 }
17387
17388 910117 break;
17389
17390 case EWPNCOLLDET:
17391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20016 times.
20016 if(0!=(s=checkEWpn(ri->ewpn,"CollDetection")))
17392 20016 (((weapon*)(s))->scriptcoldet)=value/10000;
17393
17394 20016 break;
17395
17396 case EWPNENGINEANIMATE:
17397 if(0!=(s=checkEWpn(ri->ewpn,"Animation")))
17398 (((weapon*)(s))->do_animation)=(value ? 1 : 0);
17399
17400 break;
17401
17402
17403 case EWPNPARENTUID:
17404 if(0!=(s=checkEWpn(ri->ewpn, "ParentUID")))
17405 (((weapon*)(s))->parent_script_UID) = value; //literal, not *10000
17406 break;
17407
17408 case EWPNPARENT:
17409 if(0!=(s=checkEWpn(ri->ewpn, "Parent")))
17410 (((weapon*)(s))->parentid)= ( (get_qr(qr_OLDEWPNPARENT)) ? value / 10000 : value );
17411
17412 break;
17413
17414 case EWPNSCRIPT:
17415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1275 times.
1275 if(0!=(s=checkEWpn(ri->ewpn,"Script")))
17416 {
17417 1275 FFScript::deallocateAllArrays(ScriptType::Ewpn, ri->ewpn);
17418 1275 (((weapon*)(s))->weaponscript)=vbound(value/10000,0,NUMSCRIPTWEAPONS-1);
17419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1275 times.
1275 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
17420 {
17421
2/2
✓ Branch 0 taken 10200 times.
✓ Branch 1 taken 1275 times.
11475 for(int32_t q=0; q<8; q++)
17422 10200 (((weapon*)(s))->weap_initd[q]) = 0;
17423 1275 }
17424 1275 }
17425 1275 break;
17426
17427 case EWPNINITD:
17428 {
17429 4214 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
17430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4214 times.
4214 if(0!=(s=checkEWpn(ri->ewpn,"InitD[]")))
17431 {
17432 4214 (((weapon*)(s))->weap_initd[a])=value;
17433 4214 }
17434 4214 break;
17435 }
17436 case EWPNFALLCLK:
17437 if(0!=(s=checkEWpn(ri->ewpn,"Falling")))
17438 {
17439 if(((weapon*)(s))->fallclk != 0 && value == 0)
17440 {
17441 ((weapon*)(s))->cs = ((weapon*)(s))->old_cset;
17442 ((weapon*)(s))->tile = ((weapon*)(s))->o_tile;
17443 }
17444 else if(((weapon*)(s))->fallclk == 0 && value != 0) ((weapon*)(s))->old_cset = ((weapon*)(s))->cs;
17445 ((weapon*)(s))->fallclk = vbound(value/10000,0,70);
17446 }
17447 break;
17448 case EWPNFALLCMB:
17449 if(0!=(s=checkEWpn(ri->ewpn,"FallCombo")))
17450 {
17451 ((weapon*)(s))->fallCombo = vbound(value/10000,0,MAXCOMBOS-1);
17452 }
17453 break;
17454 case EWPNDROWNCLK:
17455 if(0!=(s=checkEWpn(ri->ewpn,"Drowning")))
17456 {
17457 if(((weapon*)(s))->drownclk != 0 && value == 0)
17458 {
17459 ((weapon*)(s))->cs = ((weapon*)(s))->old_cset;
17460 ((weapon*)(s))->tile = ((weapon*)(s))->o_tile;
17461 }
17462 else if(((weapon*)(s))->drownclk == 0 && value != 0) ((weapon*)(s))->old_cset = ((weapon*)(s))->cs;
17463 ((weapon*)(s))->drownclk = vbound(value/10000,0,70);
17464 }
17465 break;
17466 case EWPNDROWNCMB:
17467 if(0!=(s=checkEWpn(ri->ewpn,"DrownCombo")))
17468 {
17469 ((weapon*)(s))->drownCombo = vbound(value/10000,0,MAXCOMBOS-1);
17470 }
17471 break;
17472 case EWPNFAKEZ:
17473 if(0!=(s=checkEWpn(ri->ewpn,"FakeZ")))
17474 {
17475 ((weapon*)s)->fakez=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
17476 if(((weapon*)s)->fakez < 0) ((weapon*)s)->fakez = zfix(0);
17477 }
17478
17479 break;
17480
17481 case EWPNMOVEFLAGS:
17482 {
17483 if(0!=(s=checkEWpn(ri->ewpn,"MoveFlags[]")))
17484 {
17485 int32_t indx = ri->d[rINDEX]/10000;
17486 if(BC::checkBounds(indx, 0, 10, "eweapon->MoveFlags[]") == SH::_NoError)
17487 {
17488 //All bits, in order, of a single byte; just use bitwise
17489 int32_t bit = 1<<indx;
17490 if(value)
17491 ((weapon*)(s))->moveflags |= bit;
17492 else
17493 ((weapon*)(s))->moveflags &= ~bit;
17494 }
17495 }
17496 break;
17497 }
17498 case EWPNFLAGS:
17499 {
17500 if(0!=(s=checkEWpn(ri->ewpn,"Flags[]")))
17501 {
17502 int32_t indx = ri->d[rINDEX]/10000;
17503 if(BC::checkBounds(indx, 0, WFLAG_MAX, "eweapon->Flags[]") == SH::_NoError)
17504 {
17505 //All bits, in order, of a single byte; just use bitwise
17506 int32_t bit = 1<<indx;
17507 if(value)
17508 ((weapon*)(s))->misc_wflags |= bit;
17509 else
17510 ((weapon*)(s))->misc_wflags &= ~bit;
17511 }
17512 }
17513 break;
17514 }
17515
17516 case EWPNGLOWRAD:
17517 if(0!=(s=checkEWpn(ri->ewpn,"LightRadius")))
17518 {
17519 ((weapon*)(s))->glowRad = vbound(value/10000,0,255);
17520 }
17521 break;
17522 case EWPNGLOWSHP:
17523 if(0!=(s=checkEWpn(ri->ewpn,"LightShape")))
17524 {
17525 ((weapon*)(s))->glowShape = vbound(value/10000,0,255);
17526 }
17527 break;
17528
17529 case EWPNUNBL:
17530 if(0!=(s=checkEWpn(ri->ewpn,"Unblockable")))
17531 {
17532 ((weapon*)(s))->unblockable = (value/10000)&WPNUNB_ALL;
17533 }
17534 break;
17535
17536 case EWPNSHADOWSPR:
17537 if(0!=(s=checkEWpn(ri->ewpn,"ShadowSprite")))
17538 {
17539 ((weapon*)(s))->spr_shadow = vbound(value/10000, 0, 255);
17540 }
17541 break;
17542 case EWSWHOOKED:
17543 break; //read-only
17544 case EWPNTIMEOUT:
17545 if(0!=(s=checkEWpn(ri->ewpn,"Timeout")))
17546 {
17547 ((weapon*)(s))->weap_timeout = vbound(value/10000,0,214748);
17548 }
17549 break;case EWPNDEATHITEM:
17550 if(0!=(s=checkEWpn(ri->ewpn,"DeathItem")))
17551 {
17552 ((weapon*)(s))->death_spawnitem = vbound(value/10000,-1,MAXITEMS-1);
17553 }
17554 break;
17555 case EWPNDEATHDROPSET:
17556 if(0!=(s=checkEWpn(ri->ewpn,"DeathDropset")))
17557 {
17558 ((weapon*)(s))->death_spawndropset = vbound(value/10000,-1,MAXITEMDROPSETS-1);
17559 }
17560 break;
17561 case EWPNDEATHIPICKUP:
17562 if(0!=(s=checkEWpn(ri->ewpn,"DeathItemPFlags")))
17563 {
17564 ((weapon*)(s))->death_item_pflags = value/10000;
17565 }
17566 break;
17567 case EWPNDEATHSPRITE:
17568 if(0!=(s=checkEWpn(ri->ewpn,"DeathSprite")))
17569 {
17570 ((weapon*)(s))->death_sprite = vbound(value/10000,-255,MAXWPNS-1);
17571 }
17572 break;
17573 case EWPNDEATHSFX:
17574 if(0!=(s=checkEWpn(ri->ewpn,"DeathSFX")))
17575 {
17576 ((weapon*)(s))->death_sfx = vbound(value/10000,0,WAV_COUNT);
17577 }
17578 break;
17579 case EWPNLIFTLEVEL:
17580 if(0!=(s=checkEWpn(ri->ewpn,"LiftLevel")))
17581 {
17582 ((weapon*)(s))->lift_level = vbound(value/10000,0,255);
17583 }
17584 break;
17585 case EWPNLIFTTIME:
17586 if(0!=(s=checkEWpn(ri->ewpn,"LiftTime")))
17587 {
17588 ((weapon*)(s))->lift_time = vbound(value/10000,0,255);
17589 }
17590 break;
17591 case EWPNLIFTHEIGHT:
17592 if(0!=(s=checkEWpn(ri->ewpn,"LiftHeight")))
17593 {
17594 ((weapon*)(s))->lift_height = zslongToFix(value);
17595 }
17596 break;
17597
17598 ///----------------------------------------------------------------------------------------------------//
17599 //NPC Variables
17600
17601 //Fixs are all a bit different
17602 case NPCX:
17603 {
17604
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1036999 times.
1037003 if(GuyH::loadNPC(ri->guyref, "npc->X") == SH::_NoError)
17605 {
17606
2/2
✓ Branch 0 taken 95921 times.
✓ Branch 1 taken 941078 times.
1036999 GuyH::getNPC()->x = get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
17607
17608
1/2
✓ Branch 0 taken 1036999 times.
✗ Branch 1 not taken.
1036999 if(GuyH::hasHero())
17609 Hero.setXfix(get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
17610 1036999 }
17611 }
17612 1037003 break;
17613
17614 case NPCSCALE:
17615 {
17616 if ( get_qr(qr_OLDSPRITEDRAWS) )
17617 {
17618 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
17619 "npc->Scale");
17620 break;
17621 }
17622 if(GuyH::loadNPC(ri->guyref, "npc->Scale") == SH::_NoError)
17623 {
17624 GuyH::getNPC()->scale = (value / 100.0);
17625 }
17626 }
17627 break;
17628
17629 case NPCIMMORTAL:
17630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(GuyH::loadNPC(ri->guyref, "npc->Immortal") == SH::_NoError)
17631 {
17632 3 GuyH::getNPC()->immortal = (value ? true : false);
17633 3 }
17634 3 break;
17635
17636 case NPCNOSLIDE:
17637 if(GuyH::loadNPC(ri->guyref, "npc->NoSlide") == SH::_NoError)
17638 {
17639 if(value)
17640 {
17641 GuyH::getNPC()->knockbackflags |= FLAG_NOSLIDE;
17642 }
17643 else
17644 {
17645 GuyH::getNPC()->knockbackflags &= ~FLAG_NOSLIDE;
17646 }
17647 }
17648 break;
17649
17650 case NPCNOSCRIPTKB:
17651 if(GuyH::loadNPC(ri->guyref, "npc->NoScriptKnockback") == SH::_NoError)
17652 {
17653 if(value)
17654 {
17655 GuyH::getNPC()->knockbackflags |= FLAG_NOSCRIPTKNOCKBACK;
17656 }
17657 else
17658 {
17659 GuyH::getNPC()->knockbackflags &= ~FLAG_NOSCRIPTKNOCKBACK;
17660 }
17661 }
17662 break;
17663
17664 case NPCKNOCKBACKSPEED:
17665 if(GuyH::loadNPC(ri->guyref, "npc->NoKnockback") == SH::_NoError)
17666 {
17667 GuyH::getNPC()->knockbackSpeed = vbound(value/10000, 0, 255);
17668 }
17669 break;
17670
17671 case SPRITEMAXNPC:
17672 {
17673 //No bounds check, as this is a universal function and works from NULL pointers!
17674 guys.setMax(vbound((value/10000),1,MAX_NPC_SPRITES));
17675 break;
17676 }
17677
17678 case NPCY:
17679 {
17680
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 1041350 times.
1041414 if(GuyH::loadNPC(ri->guyref, "npc->Y") == SH::_NoError)
17681 {
17682 1041350 zfix oldy = GuyH::getNPC()->y;
17683
2/2
✓ Branch 0 taken 95921 times.
✓ Branch 1 taken 945429 times.
1041350 GuyH::getNPC()->y = get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
17684
2/2
✓ Branch 0 taken 95921 times.
✓ Branch 1 taken 945429 times.
1041350 GuyH::getNPC()->floor_y += ((get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000)) - oldy);
17685
17686
1/2
✓ Branch 0 taken 1041350 times.
✗ Branch 1 not taken.
1041350 if(GuyH::hasHero())
17687 Hero.setYfix(get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
17688 1041350 }
17689 }
17690 1041414 break;
17691
17692 case NPCZ:
17693 {
17694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 969235 times.
969235 if(GuyH::loadNPC(ri->guyref, "npc->Z") == SH::_NoError)
17695 {
17696
2/2
✓ Branch 0 taken 1114 times.
✓ Branch 1 taken 968121 times.
969235 if(!never_in_air(GuyH::getNPC()->id))
17697 {
17698
1/2
✓ Branch 0 taken 968121 times.
✗ Branch 1 not taken.
968121 if(value < 0)
17699 GuyH::getNPC()->z = zfix(0);
17700 else
17701
2/2
✓ Branch 0 taken 95728 times.
✓ Branch 1 taken 872393 times.
968121 GuyH::getNPC()->z = get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
17702
17703
1/2
✓ Branch 0 taken 968121 times.
✗ Branch 1 not taken.
968121 if(GuyH::hasHero())
17704 Hero.setZfix(get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
17705 968121 }
17706 969235 }
17707 }
17708 969235 break;
17709
17710 case NPCJUMP:
17711 {
17712
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 972076 times.
972500 if(GuyH::loadNPC(ri->guyref, "npc->Jump") == SH::_NoError)
17713 {
17714
2/2
✓ Branch 0 taken 56049 times.
✓ Branch 1 taken 916027 times.
972076 if(canfall(GuyH::getNPC()->id))
17715 916027 GuyH::getNPC()->fall =zslongToFix(value)*-100;
17716
17717
1/2
✓ Branch 0 taken 972076 times.
✗ Branch 1 not taken.
972076 if(GuyH::hasHero())
17718 Hero.setFall(zslongToFix(value)*-100);
17719 972076 }
17720 }
17721 972500 break;
17722
17723 case NPCFAKEJUMP:
17724 {
17725 if(GuyH::loadNPC(ri->guyref, "npc->FakeJump") == SH::_NoError)
17726 {
17727 if(canfall(GuyH::getNPC()->id))
17728 GuyH::getNPC()->fakefall =zslongToFix(value)*-100;
17729
17730 if(GuyH::hasHero())
17731 Hero.setFakeFall(zslongToFix(value)*-100);
17732 }
17733 }
17734 break;
17735
17736 case NPCSTEP:
17737 {
17738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 if(GuyH::loadNPC(ri->guyref, "npc->Step") == SH::_NoError)
17739 {
17740
2/4
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 71 times.
✗ Branch 3 not taken.
71 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
17741 {
17742 71 GuyH::getNPC()->step = zslongToFix(value / 100);
17743 71 }
17744 else
17745 {
17746 //old, buggy code replication, round two: Go! -Z
17747 //zfix val = zslongToFix(value);
17748 //val.doFloor();
17749 //GuyH::getNPC()->step = ((val / 100.0).getFloat());
17750
17751 //old, buggy code replication, round THREE: Go! -Z
17752 GuyH::getNPC()->step = ((value/10000)/100.0);
17753 }
17754 71 }
17755 }
17756 71 break;
17757
17758 case NPCGRAVITY:
17759 {
17760 if(GuyH::loadNPC(ri->guyref, "npc->Gravity") == SH::_NoError)
17761 {
17762 if(value)
17763 GuyH::getNPC()->moveflags |= FLAG_OBEYS_GRAV;
17764 else
17765 GuyH::getNPC()->moveflags &= ~FLAG_OBEYS_GRAV;
17766 }
17767 }
17768 break;
17769
17770 case NPCXOFS:
17771 {
17772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21219 times.
21219 if(GuyH::loadNPC(ri->guyref, "npc->DrawXOffset") == SH::_NoError)
17773 21219 GuyH::getNPC()->xofs = zfix(value / 10000);
17774 }
17775 21219 break;
17776
17777 case NPCYOFS:
17778 {
17779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28037 times.
28037 if(GuyH::loadNPC(ri->guyref, "npc->DrawYOffset") == SH::_NoError)
17780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28037 times.
28037 GuyH::getNPC()->yofs = zfix(value / 10000) + (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17781 }
17782 28037 break;
17783
17784 case NPCSHADOWXOFS:
17785 {
17786 if(GuyH::loadNPC(ri->guyref, "npc->ShadowXOffset") == SH::_NoError)
17787 GuyH::getNPC()->shadowxofs = zfix(value / 10000);
17788 }
17789 break;
17790
17791 case NPCSHADOWYOFS:
17792 {
17793 if(GuyH::loadNPC(ri->guyref, "npc->ShadowYOffset") == SH::_NoError)
17794 GuyH::getNPC()->shadowyofs = zfix(value / 10000);
17795 }
17796 break;
17797
17798 case NPCTOTALDYOFFS:
17799 break; //READ-ONLY
17800
17801 case NPCROTATION:
17802 {
17803 if ( get_qr(qr_OLDSPRITEDRAWS) )
17804 {
17805 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
17806 "npc->Rotation");
17807 break;
17808 }
17809 if(GuyH::loadNPC(ri->guyref, "npc->Rotation") == SH::_NoError)
17810 GuyH::getNPC()->rotation = (value / 10000);
17811 }
17812 break;
17813
17814 case NPCZOFS:
17815 {
17816 if(GuyH::loadNPC(ri->guyref, "npc->DrawZOffset") == SH::_NoError)
17817 GuyH::getNPC()->zofs = zfix(value / 10000);
17818 }
17819 break;
17820
17821 #define SET_NPC_VAR_INT(member, str) \
17822 { \
17823 if(GuyH::loadNPC(ri->guyref, str) == SH::_NoError) \
17824 GuyH::getNPC()->member = value / 10000; \
17825 }
17826
17827
17828 case NPCISCORE:
17829 if(GuyH::loadNPC(ri->guyref, "npc->isCore") == SH::_NoError)
17830 GuyH::getNPC()->isCore = ( (value / 10000) ? true : false );
17831 break;
17832
17833
17834 case NPCDIR:
17835
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1045176 times.
1045600 SET_NPC_VAR_INT(dir, "npc->Dir") break;
17836
17837 case NPCHITDIR:
17838 if(GuyH::loadNPC(ri->guyref, "npc->HitDir") != SH::_NoError)
17839 (GuyH::getNPC()->hitdir) = vbound(value/10000, 0, 3);
17840
17841 break;
17842
17843 case NPCSLIDECLK:
17844 if(GuyH::loadNPC(ri->guyref, "npc->SlideClock") != SH::_NoError)
17845 GuyH::getNPC()->sclk = value/10000;//vbound(value/10000,0,255);
17846
17847 break;
17848
17849 case NPCFADING:
17850 if(GuyH::loadNPC(ri->guyref, "npc->Fading") != SH::_NoError)
17851 (GuyH::getNPC()->fading) = vbound(value/10000,0,4);
17852
17853 break;
17854
17855 case NPCHALTCLK:
17856 if(GuyH::loadNPC(ri->guyref, "npc->Halt") != SH::_NoError)
17857 (GuyH::getNPC()->clk2) = vbound(value/10000,0,214748);
17858
17859 break;
17860
17861 case NPCFRAME:
17862 if(GuyH::loadNPC(ri->guyref, "npc->Frame") != SH::_NoError)
17863 (GuyH::getNPC()->clk2) = vbound(value/10000,0,214748);
17864
17865 break;
17866
17867 case NPCMOVESTATUS:
17868 if(GuyH::loadNPC(ri->guyref, "npc->MoveStatus") != SH::_NoError)
17869 (GuyH::getNPC()->movestatus) = vbound(value/10000,0,3);
17870
17871 break;
17872
17873 case NPCRATE:
17874 SET_NPC_VAR_INT(rate, "npc->Rate") break;
17875
17876 case NPCHOMING:
17877 SET_NPC_VAR_INT(homing, "npc->Homing") break;
17878
17879 case NPCFRAMERATE:
17880 SET_NPC_VAR_INT(frate, "npc->ASpeed") break;
17881
17882 case NPCHALTRATE:
17883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 SET_NPC_VAR_INT(hrate, "npc->HaltRate") break;
17884
17885 case NPCRANDOM:
17886 SET_NPC_VAR_INT(rate, "npc->Random") break;
17887
17888 case NPCDRAWTYPE:
17889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4414 times.
4414 SET_NPC_VAR_INT(drawstyle, "npc->DrawStyle") break;
17890
17891 case NPCHP:
17892
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 1032467 times.
1032892 SET_NPC_VAR_INT(hp, "npc->HP") break;
17893
17894 case NPCORIGINALHP:
17895 SET_NPC_VAR_INT(starting_hp, "npc->OriginalHP") break;
17896
17897 //case NPCID: SET_NPC_VAR_INT(id, "npc->ID") break; ~Disallowed
17898 case NPCDP:
17899
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 784 times.
788 SET_NPC_VAR_INT(dp, "npc->Damage") break;
17900
17901 case NPCTYPE:
17902 {
17903 SET_NPC_VAR_INT(family, "npc->Type") break;
17904 }
17905
17906 case NPCWDP:
17907
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 317 times.
321 SET_NPC_VAR_INT(wdp, "npc->WeaponDamage") break;
17908
17909 case NPCITEMSET:
17910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 SET_NPC_VAR_INT(item_set, "npc->ItemSet") break;
17911
17912 case NPCBOSSPAL:
17913 SET_NPC_VAR_INT(bosspal, "npc->BossPal") break;
17914
17915 case NPCBGSFX:
17916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(GuyH::loadNPC(ri->guyref, "npc->SFX") == SH::_NoError)
17917 {
17918 13 enemy *en=GuyH::getNPC();
17919 13 int32_t newSFX = value / 10000;
17920
17921 // Stop the old sound and start the new one
17922
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if(en->bgsfx != newSFX)
17923 {
17924 2 en->stop_bgsfx(GuyH::getNPCIndex(ri->guyref));
17925 2 cont_sfx(newSFX);
17926 2 en->bgsfx = newSFX;
17927 2 }
17928 13 }
17929 13 break;
17930
17931
17932 case NPCEXTEND:
17933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77610 times.
77610 SET_NPC_VAR_INT(extend, "npc->Extend") break;
17934
17935 case NPCHXOFS:
17936
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 749 times.
1181 SET_NPC_VAR_INT(hxofs, "npc->HitXOffset") break;
17937
17938 case NPCHYOFS:
17939
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 3751 times.
4183 SET_NPC_VAR_INT(hyofs, "npc->HitYOffset") break;
17940
17941 case NPCHXSZ:
17942
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 6635 times.
7067 SET_NPC_VAR_INT(hit_width, "npc->HitWidth") break;
17943
17944 case NPCHYSZ:
17945
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 6635 times.
7067 SET_NPC_VAR_INT(hit_height, "npc->HitHeight") break;
17946
17947 case NPCHZSZ:
17948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 SET_NPC_VAR_INT(hzsz, "npc->HitZHeight") break;
17949
17950 case NPCCOLLDET:
17951
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 28754 times.
28758 SET_NPC_VAR_INT(scriptcoldet, "npc->CollDetection") break;
17952
17953 case NPCENGINEANIMATE:
17954 SET_NPC_VAR_INT(do_animation, "npc->Animation") break;
17955
17956 case NPCSTUN:
17957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1094 times.
1094 SET_NPC_VAR_INT(stunclk, "npc->Stun") break;
17958
17959 case NPCHUNGER:
17960 SET_NPC_VAR_INT(grumble, "npc->Hunger") break;
17961
17962 case NPCWEAPSPRITE:
17963 SET_NPC_VAR_INT(wpnsprite, "npc->WeaponSprite") break;
17964
17965 case NPCCSET:
17966 {
17967
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 1018836 times.
1019271 if(GuyH::loadNPC(ri->guyref, "npc->CSet") == SH::_NoError)
17968 {
17969 1018836 GuyH::getNPC()->cs = (value / 10000) & 0xF;
17970
1/2
✓ Branch 0 taken 1018836 times.
✗ Branch 1 not taken.
1018836 if(GuyH::getNPC()->family == eeLEV) GuyH::getNPC()->dcset = (value / 10000) & 0xF;
17971 1018836 }
17972 }
17973 1019271 break;
17974
17975 //Bounds on value
17976 case NPCTXSZ:
17977 {
17978 10538 int32_t height = value / 10000;
17979
17980
3/4
✓ Branch 0 taken 10102 times.
✓ Branch 1 taken 436 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10102 times.
10538 if(GuyH::loadNPC(ri->guyref, "npc->TileWidth") == SH::_NoError &&
17981 10102 BC::checkBounds(height, 0, 20, "npc->TileWidth") == SH::_NoError)
17982 10102 GuyH::getNPC()->txsz = height;
17983 }
17984 10538 break;
17985
17986 case NPCTYSZ:
17987 {
17988 10538 int32_t width = value / 10000;
17989
17990
3/4
✓ Branch 0 taken 10102 times.
✓ Branch 1 taken 436 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10102 times.
10538 if(GuyH::loadNPC(ri->guyref, "npc->TileHeight") == SH::_NoError &&
17991 10102 BC::checkBounds(width, 0, 20, "npc->TileHeight") == SH::_NoError)
17992 10102 GuyH::getNPC()->tysz = width;
17993 }
17994 10538 break;
17995
17996 case NPCOTILE:
17997 {
17998 8695 int32_t tile = value / 10000;
17999
18000
3/4
✓ Branch 0 taken 8688 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8688 times.
8695 if(GuyH::loadNPC(ri->guyref, "npc->OriginalTile") == SH::_NoError &&
18001 8688 BC::checkTile(tile, "npc->OriginalTile") == SH::_NoError)
18002 8688 GuyH::getNPC()->o_tile = tile;
18003 }
18004 8695 break;
18005
18006 case NPCTILE:
18007 {
18008 4911 int32_t tile = value / 10000;
18009
18010
2/4
✓ Branch 0 taken 4911 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4911 times.
4911 if(GuyH::loadNPC(ri->guyref, "npc->Tile") == SH::_NoError &&
18011 4911 BC::checkTile(tile, "npc->Tile") == SH::_NoError)
18012 4911 GuyH::getNPC()->tile = tile;
18013 }
18014 4911 break;
18015
18016 case NPCSCRIPTTILE:
18017 {
18018 if(GuyH::loadNPC(ri->guyref, "npc->ScriptTile") == SH::_NoError)
18019 GuyH::getNPC()->scripttile = vbound((value/10000),-1, NEWMAXTILES-1);
18020 }
18021 break;
18022
18023 case NPCSCRIPTFLIP:
18024 {
18025 if(GuyH::loadNPC(ri->guyref, "npc->ScriptFlip") == SH::_NoError )
18026 GuyH::getNPC()->scriptflip = vbound(value/10000, -1, 127);
18027 }
18028 break;
18029
18030 case NPCWEAPON:
18031 {
18032 int32_t weapon = value / 10000;
18033
18034 if(GuyH::loadNPC(ri->guyref, "npc->Weapon") == SH::_NoError &&
18035 BC::checkBounds(weapon, 0, MAXWPNS-1, "npc->Weapon") == SH::_NoError)
18036 {
18037 GuyH::getNPC()->wpn = weapon;
18038
18039 //al_trace("Correct weapon sprite is: %d /n", FFCore.GetDefaultWeaponSprite(weapon));
18040 if ( get_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE) ) //this should probably just be an extra_rule
18041 {
18042 GuyH::getNPC()->wpnsprite = FFCore.GetDefaultWeaponSprite(weapon);
18043 }
18044 //else GuyH::getNPC()->wpnsprite = FFCore.GetDefaultWeaponSprite(weapon); //just to test that this works.
18045 }
18046 }
18047 break;
18048
18049 //Indexed
18050 case NPCDEFENSED:
18051 {
18052 545362 int32_t a = ri->d[rINDEX] / 10000;
18053
18054
2/4
✓ Branch 0 taken 545362 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 545362 times.
545362 if(GuyH::loadNPC(ri->guyref, "npc->Defense") == SH::_NoError &&
18055 545362 BC::checkBounds(a, 0, (edefLAST255), "npc->Defense") == SH::_NoError)
18056 {
18057
4/4
✓ Branch 0 taken 545278 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 521697 times.
✓ Branch 3 taken 23581 times.
545362 if ( ( get_qr(qr_250WRITEEDEFSCRIPT) ) && a == edefSCRIPT )
18058 {
18059
2/2
✓ Branch 0 taken 235810 times.
✓ Branch 1 taken 23581 times.
259391 for ( int32_t sd = edefSCRIPT01; sd <= edefSCRIPT10; sd++ )
18060 {
18061 235810 GuyH::getNPC()->defense[sd] = vbound((value / 10000),0,255);
18062 235810 }
18063 23581 }
18064 //no else here, is intentional as a fallthrough. -Z
18065 545362 GuyH::getNPC()->defense[a] = vbound((value / 10000),0,255);
18066 545362 }
18067 }
18068 545362 break;
18069
18070 case NPCPARENTUID:
18071 if(GuyH::loadNPC(ri->guyref, "npc->ParentUID") == SH::_NoError)
18072 {
18073 GuyH::getNPC()->parent_script_UID = value; //literal, not *10000
18074 }
18075 break;
18076
18077 case NPCHITBY:
18078 {
18079 int32_t indx = ri->d[rINDEX] / 10000;
18080
18081 if(GuyH::loadNPC(ri->guyref, "npc->HitBy[]") == SH::_NoError)
18082 {
18083 switch(indx)
18084 {
18085 //screen index objects
18086 case 0:
18087 case 1:
18088 case 2:
18089 case 3:
18090 case 8:
18091 case 9:
18092 case 10:
18093 case 11:
18094 case 12:
18095 case 16:
18096 {
18097 GuyH::getNPC()->hitby[indx] = vbound((value / 10000),0,255); //Once again, why did I vbound this, and why did I allow it to be written? UIDs are LONGs, with a starting value of 0.0001. -Z
18098 break;
18099 }
18100 //UIDs
18101 case 4:
18102 case 5:
18103 case 6:
18104 case 7:
18105 case 13:
18106 case 14:
18107 case 15:
18108 {
18109 GuyH::getNPC()->hitby[indx] = value; //Once again, why did I vbound this, and why did I allow it to be written? UIDs are LONGs, with a starting value of 0.0001. -Z
18110 break;
18111 }
18112 default: al_trace("Invalid index used with npc->hitBy[%d]. /n", indx); break;
18113 }
18114 }
18115 break;
18116 }
18117
18118 //2.future compat. -Z
18119
18120
18121 case NPCSCRDEFENSED:
18122 {
18123 int32_t a = ri->d[rINDEX] / 10000;
18124
18125 if(GuyH::loadNPC(ri->guyref, "npc->ScriptDefense") == SH::_NoError &&
18126 BC::checkBounds(a, 0, edefSCRIPTDEFS_MAX, "npc->ScriptDefense") == SH::_NoError)
18127 GuyH::getNPC()->defense[a+edefSCRIPT01] = value / 10000;
18128 }
18129 break;
18130
18131 case NPCMISCD:
18132 {
18133 2612168 int32_t a = ri->d[rINDEX] / 10000;
18134
18135
3/4
✓ Branch 0 taken 2612129 times.
✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2612129 times.
2612168 if(GuyH::loadNPC(ri->guyref, "npc->Misc") == SH::_NoError &&
18136 2612129 BC::checkMisc32(a, "npc->Misc") == SH::_NoError)
18137 2612129 GuyH::getNPC()->miscellaneous[a] = value;
18138
18139 }
18140
18141 2612168 break;
18142
18143 case NPCINITD:
18144 {
18145 int32_t a = ri->d[rINDEX] / 10000;
18146
18147 if(GuyH::loadNPC(ri->guyref, "npc->InitD[]") == SH::_NoError)
18148 {
18149 //enemy *e = (enemy*)guys.spr(ri->guyref);
18150 //e->initD[a] = value;
18151 GuyH::getNPC()->initD[a] = value;
18152 }
18153 }
18154 break;
18155
18156 case NPCSCRIPT:
18157 {
18158 if(GuyH::loadNPC(ri->guyref, "npc->Script") == SH::_NoError)
18159 {
18160 FFScript::deallocateAllArrays(ScriptType::NPC, ri->guyref);
18161 //enemy *e = (enemy*)guys.spr(ri->guyref);
18162 //e->initD[a] = value;
18163 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
18164 {
18165 for(int32_t q=0; q<8; q++)
18166 GuyH::getNPC()->initD[q] = 0;
18167 }
18168 GuyH::getNPC()->script = vbound((value/10000), 0, NUMSCRIPTGUYS-1);
18169 }
18170 }
18171 break;
18172
18173 //npc->Attributes[] setter -Z
18174 case NPCDD:
18175 {
18176 int32_t a = ri->d[rINDEX] / 10000;
18177
18178 if(GuyH::loadNPC(ri->guyref, "npc->Attributes") == SH::_NoError &&
18179 BC::checkBounds(a, 0, 31, "npc->Attributes") == SH::_NoError)
18180
18181 switch(a)
18182 {
18183 case 0: GuyH::getNPC()->dmisc1 = value / 10000; break;
18184 case 1: GuyH::getNPC()->dmisc2 = value / 10000; break;
18185 case 2: GuyH::getNPC()->dmisc3 = value / 10000; break;
18186 case 3: GuyH::getNPC()->dmisc4 = value / 10000; break;
18187 case 4: GuyH::getNPC()->dmisc5 = value / 10000; break;
18188 case 5: GuyH::getNPC()->dmisc6 = value / 10000; break;
18189 case 6: GuyH::getNPC()->dmisc7 = value / 10000; break;
18190 case 7: GuyH::getNPC()->dmisc8 = value / 10000; break;
18191 case 8: GuyH::getNPC()->dmisc9 = value / 10000; break;
18192 case 9: GuyH::getNPC()->dmisc10 = value / 10000; break;
18193 case 10: GuyH::getNPC()->dmisc11 = value / 10000; break;
18194 case 11: GuyH::getNPC()->dmisc12 = value / 10000; break;
18195 case 12: GuyH::getNPC()->dmisc13 = value / 10000; break;
18196 case 13: GuyH::getNPC()->dmisc14 = value / 10000; break;
18197 case 14: GuyH::getNPC()->dmisc15 = value / 10000; break;
18198 case 15: GuyH::getNPC()->dmisc16 = value / 10000; break;
18199 case 16: GuyH::getNPC()->dmisc17 = value / 10000; break;
18200 case 17: GuyH::getNPC()->dmisc18 = value / 10000; break;
18201 case 18: GuyH::getNPC()->dmisc19 = value / 10000; break;
18202 case 19: GuyH::getNPC()->dmisc20 = value / 10000; break;
18203 case 20: GuyH::getNPC()->dmisc21 = value / 10000; break;
18204 case 21: GuyH::getNPC()->dmisc22 = value / 10000; break;
18205 case 22: GuyH::getNPC()->dmisc23 = value / 10000; break;
18206 case 23: GuyH::getNPC()->dmisc24 = value / 10000; break;
18207 case 24: GuyH::getNPC()->dmisc25 = value / 10000; break;
18208 case 25: GuyH::getNPC()->dmisc26 = value / 10000; break;
18209 case 26: GuyH::getNPC()->dmisc27 = value / 10000; break;
18210 case 27: GuyH::getNPC()->dmisc28 = value / 10000; break;
18211 case 28: GuyH::getNPC()->dmisc28 = value / 10000; break;
18212 case 29: GuyH::getNPC()->dmisc30 = value / 10000; break;
18213 case 30: GuyH::getNPC()->dmisc31 = value / 10000; break;
18214 case 31: GuyH::getNPC()->dmisc32 = value / 10000; break;
18215 default: break;
18216 }
18217 break;
18218 }
18219
18220
18221 case NPCINVINC:
18222 {
18223 if(GuyH::loadNPC(ri->guyref, "npc->InvFrames") == SH::_NoError)
18224 GuyH::getNPC()->hclk = (int32_t)value/10000;
18225 }
18226 break;
18227
18228 case NPCSUPERMAN:
18229 {
18230 if(GuyH::loadNPC(ri->guyref, "npc->Invincible") == SH::_NoError)
18231 GuyH::getNPC()->superman = (int32_t)value/10000;
18232 }
18233 break;
18234
18235 case NPCHASITEM:
18236 {
18237 if(GuyH::loadNPC(ri->guyref, "npc->HasItem") == SH::_NoError)
18238 GuyH::getNPC()->itemguy = (value/10000)?1:0;
18239 }
18240 break;
18241
18242 case NPCRINGLEAD:
18243 {
18244 if(GuyH::loadNPC(ri->guyref, "npc->Ringleader") == SH::_NoError)
18245 GuyH::getNPC()->leader = (value/10000)?1:0;
18246 }
18247 break;
18248
18249 case NPCSHIELD:
18250 {
18251 int32_t indx = ri->d[rINDEX];
18252 if(GuyH::loadNPC(ri->guyref, "npc->Shield[]") == SH::_NoError)
18253 {
18254 switch(indx)
18255 {
18256 case 0:
18257 {
18258 (ri->d[rINDEX2])? (GuyH::getNPC()->flags |= inv_front) : (GuyH::getNPC()->flags &= ~inv_front);
18259 break;
18260 }
18261 case 1:
18262 {
18263 (ri->d[rINDEX2])? (GuyH::getNPC()->flags |= inv_left) : (GuyH::getNPC()->flags &= ~inv_left);
18264 break;
18265 }
18266 case 2:
18267 {
18268 (ri->d[rINDEX2])? (GuyH::getNPC()->flags |= inv_right) : (GuyH::getNPC()->flags &= ~inv_right);
18269 break;
18270 }
18271 case 3:
18272 {
18273 (ri->d[rINDEX2])? (GuyH::getNPC()->flags |= inv_back) : (GuyH::getNPC()->flags &= ~inv_back);
18274 break;
18275 }
18276 case 4: //shield can be broken
18277 {
18278 (ri->d[rINDEX2])? (GuyH::getNPC()->flags |= guy_bkshield) : (GuyH::getNPC()->flags &= ~guy_bkshield);
18279 break;
18280 }
18281 default:
18282 {
18283 Z_scripterrlog("Invalid Array Index passed to npc->Shield[]: %d\n", indx);
18284 break;
18285 }
18286 }
18287 }
18288 }
18289 break;
18290
18291 case NPCFROZENTILE:
18292 SET_NPC_VAR_INT(frozentile, "npc->FrozenTile"); break;
18293 case NPCFROZENCSET:
18294 SET_NPC_VAR_INT(frozencset, "npc->FrozenCSet"); break;
18295 case NPCFROZEN:
18296 SET_NPC_VAR_INT(frozenclock, "npc->Frozen"); break;
18297
18298 case NPCBEHAVIOUR:
18299 {
18300 if(GuyH::loadNPC(ri->guyref, "npc->Behaviour[]") != SH::_NoError)
18301 {
18302 break;
18303 }
18304 int32_t index = vbound(ri->d[rINDEX]/10000,0,4);
18305 switch(index)
18306 {
18307 case 0:
18308 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG1 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG1;
18309 break;
18310 case 1:
18311 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG2 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG2;
18312 break;
18313 case 2:
18314 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG3 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG3;
18315 break;
18316 case 3:
18317 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG4 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG4;
18318 break;
18319 case 4:
18320 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG5 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG5;
18321 break;
18322 case 5:
18323 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG6 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG6;
18324 break;
18325 case 6:
18326 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG7 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG7;
18327 break;
18328 case 7:
18329 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG8 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG8;
18330 break;
18331 case 8:
18332 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG9 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG9;
18333 break;
18334 case 9:
18335 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG10 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG10;
18336 break;
18337 case 10:
18338 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG11 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG11;
18339 break;
18340 case 11:
18341 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG12 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG12;
18342 break;
18343 case 12:
18344 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG13 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG13;
18345 break;
18346 case 13:
18347 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG14 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG14;
18348 break;
18349 case 14:
18350 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG15 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG15;
18351 break;
18352 case 15:
18353 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG16 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG16;
18354 break;
18355
18356
18357 default:
18358 break;
18359 }
18360
18361 break;
18362 }
18363 case NPCFALLCLK:
18364 if(GuyH::loadNPC(ri->guyref, "npc->Falling") == SH::_NoError)
18365 {
18366 if(GuyH::getNPC()->fallclk != 0 && value == 0)
18367 {
18368 GuyH::getNPC()->cs = GuyH::getNPC()->old_cset;
18369 GuyH::getNPC()->tile = GuyH::getNPC()->o_tile;
18370 }
18371 else if(GuyH::getNPC()->fallclk == 0 && value != 0) GuyH::getNPC()->old_cset = GuyH::getNPC()->cs;
18372 GuyH::getNPC()->fallclk = vbound(value/10000,0,70);
18373 }
18374 break;
18375 case NPCFALLCMB:
18376 if(GuyH::loadNPC(ri->guyref, "npc->FallCombo") == SH::_NoError)
18377 {
18378 GuyH::getNPC()->fallCombo = vbound(value/10000,0,MAXCOMBOS-1);
18379 }
18380 break;
18381 case NPCDROWNCLK:
18382 if(GuyH::loadNPC(ri->guyref, "npc->Drowning") == SH::_NoError)
18383 {
18384 if(GuyH::getNPC()->drownclk != 0 && value == 0)
18385 {
18386 GuyH::getNPC()->cs = GuyH::getNPC()->old_cset;
18387 GuyH::getNPC()->tile = GuyH::getNPC()->o_tile;
18388 }
18389 else if(GuyH::getNPC()->drownclk == 0 && value != 0) GuyH::getNPC()->old_cset = GuyH::getNPC()->cs;
18390 GuyH::getNPC()->drownclk = vbound(value/10000,0,70);
18391 }
18392 break;
18393 case NPCDROWNCMB:
18394 if(GuyH::loadNPC(ri->guyref, "npc->DrowningCombo") == SH::_NoError)
18395 {
18396 GuyH::getNPC()->drownCombo = vbound(value/10000,0,MAXCOMBOS-1);
18397 }
18398 case NPCFAKEZ:
18399 {
18400 if(GuyH::loadNPC(ri->guyref, "npc->FakeZ") == SH::_NoError)
18401 {
18402 if(!never_in_air(GuyH::getNPC()->id))
18403 {
18404 if(value < 0)
18405 GuyH::getNPC()->fakez = zfix(0);
18406 else
18407 GuyH::getNPC()->fakez = get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
18408
18409 if(GuyH::hasHero())
18410 Hero.setFakeZfix(get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
18411 }
18412 }
18413 }
18414 break;
18415 case NPCMOVEFLAGS:
18416 {
18417 if(GuyH::loadNPC(ri->guyref, "npc->MoveFlags[]") == SH::_NoError)
18418 {
18419 int32_t indx = ri->d[rINDEX]/10000;
18420 if(BC::checkBounds(indx, 0, 15, "npc->MoveFlags[]") == SH::_NoError)
18421 {
18422 //All bits, in order, of a single byte; just use bitwise
18423 int32_t bit = 1<<indx;
18424 if(value)
18425 GuyH::getNPC()->moveflags |= bit;
18426 else
18427 GuyH::getNPC()->moveflags &= ~bit;
18428 }
18429 }
18430 break;
18431 }
18432
18433 case NPCGLOWRAD:
18434 if(GuyH::loadNPC(ri->guyref, "npc->LightRadius") == SH::_NoError)
18435 {
18436 GuyH::getNPC()->glowRad = vbound(value/10000,0,255);
18437 }
18438 break;
18439 case NPCGLOWSHP:
18440 if(GuyH::loadNPC(ri->guyref, "npc->LightShape") == SH::_NoError)
18441 {
18442 GuyH::getNPC()->glowShape = vbound(value/10000,0,255);
18443 }
18444 break;
18445
18446 case NPCSHADOWSPR:
18447 if(GuyH::loadNPC(ri->guyref, "npc->ShadowSprite") == SH::_NoError)
18448 {
18449 GuyH::getNPC()->spr_shadow = vbound(value/10000,0,255);
18450 }
18451 break;
18452 case NPCSPAWNSPR:
18453 if(GuyH::loadNPC(ri->guyref, "npc->SpawnSprite") == SH::_NoError)
18454 {
18455 GuyH::getNPC()->spr_spawn = vbound(value/10000,0,255);
18456 }
18457 break;
18458 case NPCDEATHSPR:
18459 if(GuyH::loadNPC(ri->guyref, "npc->DeathSprite") == SH::_NoError)
18460 {
18461 GuyH::getNPC()->spr_death = vbound(value/10000,0,255);
18462 }
18463 break;
18464 case NPCSWHOOKED:
18465 break; //read-only
18466 case NPCCANFLICKER:
18467 if(GuyH::loadNPC(ri->guyref, "npc->InvFlicker") == SH::_NoError)
18468 {
18469 GuyH::getNPC()->setCanFlicker(value != 0);
18470 }
18471 break;
18472
18473
18474 ///----------------------------------------------------------------------------------------------------//
18475 //Game Information
18476
18477 case GAMEDEATHS:
18478 game->set_deaths(value/10000);
18479 break;
18480
18481 case GAMECHEAT:
18482 2 cheat=vbound(value/10000,0,4);
18483
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(maxcheat < cheat) maxcheat = cheat;
18484
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(cheat) game->did_cheat(true);
18485 2 break;
18486
18487 case GAMEMAXCHEAT:
18488 maxcheat=vbound(value/10000,0,4);
18489 game->set_cheat(maxcheat);
18490 if(cheat > maxcheat) cheat = maxcheat;
18491 break;
18492
18493 case GAMETIME:
18494 1 game->set_time(value);
18495 1 break; // Can't multiply by 10000 or the maximum result is too big
18496
18497 case ACTIVESSSPEED:
18498 Hero.subscr_speed = vbound((value/10000),1,85);
18499 break; // Can't multiply by 10000 or the maximum result is too big
18500
18501 case GAMETIMEVALID:
18502 game->set_timevalid((value/10000)?1:0);
18503 break;
18504
18505 case GAMEHASPLAYED:
18506 game->set_hasplayed((value/10000)?1:0);
18507 break;
18508
18509 case TYPINGMODE:
18510 FFCore.kb_typing_mode = ((value/10000)?true:false);
18511 break;
18512
18513 case SKIPCREDITS:
18514 FFCore.skip_ending_credits = ((value/10000)?true:false);
18515 break;
18516
18517 case SKIPF6:
18518 set_qr(qr_NOCONTINUE,((value/10000)?1:0));
18519 break;
18520
18521
18522
18523 case GAMEGUYCOUNT:
18524 {
18525 26 int32_t mi2 = (currmap*MAPSCRSNORMAL)+(ri->d[rINDEX]/10000);
18526 26 game->guys[mi2]=value/10000;
18527 }
18528 26 break;
18529
18530 case GAMECONTSCR:
18531 88964 game->set_continue_scrn(value/10000);
18532 88964 break;
18533
18534 case GAMECONTDMAP:
18535 88964 game->set_continue_dmap(value/10000);
18536 88964 break;
18537
18538 case GAMEENTRSCR:
18539 88970 lastentrance=value/10000;
18540 88970 break;
18541
18542 case GAMEENTRDMAP:
18543 88970 lastentrance_dmap=value/10000;
18544 88970 break;
18545
18546 case GAMECOUNTERD:
18547 2705905 game->set_counter(value/10000, (ri->d[rINDEX])/10000);
18548 2705905 break;
18549
18550 case GAMEMCOUNTERD:
18551 551 game->set_maxcounter(value/10000, (ri->d[rINDEX])/10000);
18552 551 break;
18553
18554 case GAMEDCOUNTERD:
18555 8 game->set_dcounter(value/10000, (ri->d[rINDEX])/10000);
18556 8 break;
18557
18558 case GAMEGENERICD:
18559 game->set_generic(value/10000, (ri->d[rINDEX])/10000);
18560 break;
18561 case GAMEMISC:
18562 {
18563 int32_t indx = ri->d[rINDEX]/10000;
18564 if ( indx < 0 || indx > 31 )
18565 {
18566 Z_scripterrlog("Invalid index used to access Game->Misc: %d\n", indx);
18567 }
18568 else
18569 {
18570 QMisc.questmisc[indx] = (value/((get_qr(qr_OLDQUESTMISC)) ? 10000 : 1));
18571 }
18572 break;
18573 }
18574 case GAMEITEMSD:
18575 game->set_item((ri->d[rINDEX])/10000,(value!=0));
18576 break;
18577
18578 case DISABLEDITEM:
18579 {
18580 int id = (ri->d[rINDEX])/10000;
18581 if(unsigned(id) >= MAXITEMS)
18582 break;
18583 game->items_off[id]=value/10000;
18584 removeFromItemCache(itemsbuf[id].family);
18585 break;
18586 }
18587
18588 case GAMESUSPEND:
18589 {
18590 131 int32_t inx = (ri->d[rINDEX])/10000;
18591
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if ( (unsigned) inx > (susptLAST-1) )
18592 {
18593 Z_scripterrlog("Invalid array index [%d] passed to Gme->Suspend[]\n");
18594 }
18595 131 FFCore.system_suspend[inx]= ( (value) ? 1 : 0 );
18596 131 break;
18597 }
18598
18599 case GAMELITEMSD:
18600 64 game->lvlitems[(ri->d[rINDEX])/10000]=value/10000;
18601 64 break;
18602 case GAMELSWITCH:
18603 {
18604 int32_t ind = (ri->d[rINDEX])/10000;
18605 if(unsigned(ind) < MAXLEVELS)
18606 game->lvlswitches[ind]=value;
18607 break;
18608 }
18609 case GAMEGSWITCH:
18610 {
18611 int32_t ind = (ri->d[rINDEX])/10000;
18612 if(unsigned(ind) < NUM_GSWITCHES)
18613 game->gswitch_timers[ind]=value/10000;
18614 break;
18615 }
18616 case GAMEBOTTLEST:
18617 game->set_bottle_slot((ri->d[rINDEX])/10000,value/10000);
18618 break;
18619
18620 case TANGOARR:
18621 {
18622 int32_t inx = (ri->d[rINDEX])/10000;
18623 if ( ((unsigned)inx) > 255 )
18624 {
18625 Z_scripterrlog("Invalid index %d supplied to Game->Tango[].\n", inx);
18626 break;
18627 }
18628 else
18629 {
18630 FFCore.TangoArray[inx]=value/10000;
18631 break;
18632 }
18633 }
18634
18635 case GHOSTARR:
18636 {
18637 int32_t inx = (ri->d[rINDEX])/10000;
18638 if ( ((unsigned)inx) > 255 )
18639 {
18640 Z_scripterrlog("Invalid index %d supplied to Game->Ghost[].\n", inx);
18641 break;
18642 }
18643 else
18644 {
18645
18646 FFCore.GhostArray[inx]=value/10000;;
18647 break;
18648 }
18649 }
18650 case STDARR:
18651 {
18652 int32_t inx = (ri->d[rINDEX])/10000;
18653 if ( ((unsigned)inx) > 255 )
18654 {
18655 Z_scripterrlog("Invalid index %d supplied to Game->STD[].\n", inx);
18656 break;
18657 }
18658 else
18659 {
18660 FFCore.StdArray[inx]=value/10000;
18661 break;
18662 }
18663 }
18664
18665 case GAMEMISCSPR:
18666 {
18667 int32_t inx = (ri->d[rINDEX])/10000;
18668 if ( ((unsigned)inx) > sprMAX )
18669 {
18670 Z_scripterrlog("Invalid index %d supplied to Game->MiscSprites[].\n", inx);
18671 }
18672 else
18673 {
18674 QMisc.sprites[inx] = vbound(value/10000, 0, 255);
18675 }
18676 break;
18677 }
18678 case GAMEMISCSFX:
18679 {
18680 int32_t inx = (ri->d[rINDEX])/10000;
18681 if ( ((unsigned)inx) > sfxMAX )
18682 {
18683 Z_scripterrlog("Invalid index %d supplied to Game->MiscSFX[].\n", inx);
18684 }
18685 else
18686 {
18687 QMisc.miscsfx[inx] = vbound(value/10000, 0, 255);
18688 }
18689 break;
18690 }
18691 case GAMEEVENTDATA:
18692 {
18693 int32_t inx = (ri->d[rINDEX])/10000;
18694 if ( ((unsigned)inx) < FFCore.eventData.size() )
18695 {
18696 FFCore.eventData[inx] = value;
18697 }
18698 break;
18699 }
18700 case GAMEMOUSECURSOR:
18701 {
18702 int v = value/10000;
18703 if(v < 0 || v >= ZCM_MAX)
18704 break;
18705 game_mouse_index = v;
18706 game_mouse();
18707 break;
18708 }
18709 case GAMETRIGGROUPS:
18710 break; //read-only
18711
18712 case GAMELKEYSD:
18713 3 game->lvlkeys[(ri->d[rINDEX])/10000]=value/10000;
18714 3 break;
18715
18716 case GAMEGRAVITY:
18717 {
18718 int32_t indx = ri->d[rINDEX]/10000;
18719 if(indx < 0 || indx > 2)
18720 {
18721 Z_scripterrlog("Invalid index used to access Game->Gravity[]: %d\n", indx);
18722 }
18723 else
18724 {
18725 switch(indx)
18726 {
18727 case 0: //Gravity Strength
18728 zinit.gravity2 = value;
18729 break;
18730 case 1: //Terminal Velocity
18731 zinit.terminalv = value / 100;
18732 break;
18733 case 2: //Sprite Layer Threshold
18734 zinit.jump_hero_layer_threshold = value / 10000;
18735 break;
18736 }
18737 }
18738 break;
18739 }
18740
18741 case SCREENSTATED:
18742 {
18743 394 int32_t mi2 = (currmap*MAPSCRSNORMAL)+currscr;
18744
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 4 times.
394 (value)?setmapflag(mi2, 1<<((ri->d[rINDEX])/10000)) : unsetmapflag(mi2, 1 << ((ri->d[rINDEX]) / 10000));
18745 }
18746 394 break;
18747 case SCREENEXSTATED:
18748 {
18749 int32_t mi2 = (currmap*MAPSCRSNORMAL)+currscr;
18750 (value)?setxmapflag(mi2, 1<<((ri->d[rINDEX])/10000)) : unsetxmapflag(mi2, 1 << ((ri->d[rINDEX]) / 10000));
18751 }
18752 break;
18753 case SCREENLENSSHOWS:
18754 {
18755 int ind = ri->d[rINDEX]/10000;
18756 if(ind < 0 || ind > 6)
18757 Z_scripterrlog("Bad index Screen->LensShows[%d]\n",ind);
18758 else
18759 {
18760 SETFLAG(tmpscr->lens_show, 1<<ind, value);
18761 if(value) tmpscr->lens_hide &= ~(1<<ind);
18762 }
18763 break;
18764 }
18765 case SCREENLENSHIDES:
18766 {
18767 int ind = ri->d[rINDEX]/10000;
18768 if(ind < 0 || ind > 6)
18769 Z_scripterrlog("Bad index Screen->LensHides[%d]\n",ind);
18770 else
18771 {
18772 SETFLAG(tmpscr->lens_hide, 1<<ind, value);
18773 if(value) tmpscr->lens_show &= ~(1<<ind);
18774 }
18775 break;
18776 }
18777
18778 case SCREENSTATEDD:
18779 {
18780 649 int32_t mi2 = ri->d[rINDEX]/10000;
18781 649 mi2 -= 8*(mi2/MAPSCRS);
18782
18783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 649 times.
649 if(BC::checkMapID(mi2>>7, "Game->SetScreenState") == SH::_NoError)
18784
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 455 times.
649 (value)?setmapflag(mi2, 1<<(ri->d[rINDEX2]/10000)) : unsetmapflag(mi2, 1 << (ri->d[rINDEX2] / 10000), true);
18785 }
18786 649 break;
18787
18788 case GAMEGUYCOUNTD:
18789 game->guys[(currmap*MAPSCRSNORMAL)+(ri->d[rINDEX]/10000)] = value / 10000;
18790 break;
18791
18792 case GAMECLICKFREEZE:
18793 disableClickToFreeze=value==0;
18794 break;
18795
18796
18797 case NOACTIVESUBSC:
18798 Hero.stopSubscreenFalling((value/10000)?1:0);
18799 break;
18800
18801 ///----------------------------------------------------------------------------------------------------//
18802 //BottleTypes
18803 case BOTTLECOUNTER:
18804 {
18805 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Counter[]"))
18806 {
18807 int32_t indx = ri->d[rINDEX]/10000;
18808 int32_t ctr = vbound(value/10000, -1, MAX_COUNTERS-1);
18809 if(unsigned(indx) > 2)
18810 {
18811 Z_scripterrlog("Invalid index %d supplied to bottledata->Counter[].\n", indx);
18812 break;
18813 }
18814 ptr->counter[indx] = ctr;
18815 }
18816 }
18817 break;
18818
18819 case BOTTLEAMOUNT:
18820 {
18821 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Amount[]"))
18822 {
18823 int32_t indx = ri->d[rINDEX]/10000;
18824 int32_t amnt = vbound(value/10000, 0, 65535);
18825 if(unsigned(indx) > 2)
18826 {
18827 Z_scripterrlog("Invalid index %d supplied to bottledata->Amount[].\n", indx);
18828 break;
18829 }
18830 ptr->amount[indx] = amnt;
18831 }
18832 }
18833 break;
18834
18835 case BOTTLEPERCENT:
18836 {
18837 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "IsPercent[]"))
18838 {
18839 int32_t indx = ri->d[rINDEX]/10000;
18840 if(unsigned(indx) > 2)
18841 {
18842 Z_scripterrlog("Invalid index %d supplied to bottledata->IsPercent[].\n", indx);
18843 break;
18844 }
18845 SETFLAG(ptr->flags, 1<<indx, value);
18846 }
18847 }
18848 break;
18849
18850 case BOTTLEFLAGS:
18851 {
18852 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Flags[]"))
18853 {
18854 int32_t indx = ri->d[rINDEX]/10000;
18855 if(unsigned(indx) > 3)
18856 {
18857 Z_scripterrlog("Invalid index %d supplied to bottledata->Flags[].\n", indx);
18858 break;
18859 }
18860 int32_t flag = 0;
18861 switch(indx)
18862 {
18863 case 0: flag = BTFLAG_AUTOONDEATH; break;
18864 case 1: flag = BTFLAG_ALLOWIFFULL; break;
18865 case 2: flag = BTFLAG_CURESWJINX; break;
18866 case 3: flag = BTFLAG_CUREITJINX; break;
18867 }
18868 SETFLAG(ptr->flags, flag, value);
18869 }
18870 }
18871 break;
18872
18873 case BOTTLENEXT:
18874 {
18875 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "NextType"))
18876 {
18877 ptr->next_type = vbound(value/10000, 0, 64);
18878 }
18879 }
18880 break;
18881 ///----------------------------------------------------------------------------------------------------//
18882 //BottleShops
18883 case BSHOPFILL:
18884 {
18885 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Fill[]"))
18886 {
18887 int32_t indx = ri->d[rINDEX]/10000;
18888 if(unsigned(indx) > 2)
18889 {
18890 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Fill[].\n", indx);
18891 break;
18892 }
18893 ptr->fill[indx] = vbound(value/10000, 0, 64);
18894 }
18895 }
18896 break;
18897
18898 case BSHOPCOMBO:
18899 {
18900 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Combo[]"))
18901 {
18902 int32_t indx = ri->d[rINDEX]/10000;
18903 if(unsigned(indx) > 2)
18904 {
18905 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Combo[].\n", indx);
18906 break;
18907 }
18908 ptr->comb[indx] = vbound(value/10000, 0, MAXCOMBOS-1);
18909 }
18910 }
18911 break;
18912
18913 case BSHOPCSET:
18914 {
18915 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "CSet[]"))
18916 {
18917 int32_t indx = ri->d[rINDEX]/10000;
18918 if(unsigned(indx) > 2)
18919 {
18920 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->CSet[].\n", indx);
18921 break;
18922 }
18923 ptr->cset[indx] = vbound(value/10000, 0, 11);
18924 }
18925 }
18926 break;
18927
18928 case BSHOPPRICE:
18929 {
18930 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Price[]"))
18931 {
18932 int32_t indx = ri->d[rINDEX]/10000;
18933 if(unsigned(indx) > 2)
18934 {
18935 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Price[].\n", indx);
18936 break;
18937 }
18938 ptr->price[indx] = vbound(value/10000, 0, 65535);
18939 }
18940 }
18941 break;
18942
18943 case BSHOPSTR:
18944 {
18945 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "InfoString[]"))
18946 {
18947 int32_t indx = ri->d[rINDEX]/10000;
18948 if(unsigned(indx) > 2)
18949 {
18950 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->InfoString[].\n", indx);
18951 break;
18952 }
18953 ptr->str[indx] = vbound(value/10000, 0, 65535);
18954 }
18955 }
18956 break;
18957 ///----------------------------------------------------------------------------------------------------//
18958 //DMap Information
18959
18960 #define SET_DMAP_VAR(member, str) \
18961 { \
18962 int32_t ID = ri->d[rINDEX] / 10000; \
18963 if(BC::checkDMapID(ID, str) == SH::_NoError) \
18964 DMaps[ID].member = value / 10000; \
18965 }
18966
18967 case DMAPFLAGSD:
18968 SET_DMAP_VAR(flags, "Game->DMapFlags") break;
18969
18970 case DMAPLEVELD:
18971 SET_DMAP_VAR(level, "Game->DMapLevel") break;
18972
18973 case DMAPCOMPASSD:
18974 SET_DMAP_VAR(compass, "Game->DMapCompass") break;
18975
18976 case DMAPCONTINUED:
18977 SET_DMAP_VAR(cont, "Game->DMapContinue") break;
18978
18979 case DMAPLEVELPAL:
18980 {
18981 889 int32_t ID = ri->d[rINDEX] / 10000;
18982 889 int32_t pal = value/10000;
18983 889 pal = vbound(pal, 0, 0x1FF);
18984
18985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 889 times.
889 if(BC::checkDMapID(ID, "Game->DMapPalette") == SH::_NoError)
18986 889 DMaps[ID].color = pal;
18987
18988
2/2
✓ Branch 0 taken 878 times.
✓ Branch 1 taken 11 times.
889 if(ID == currdmap)
18989 {
18990 11 loadlvlpal(DMaps[ID].color);
18991 11 currcset = DMaps[ID].color;
18992 11 }
18993 889 break;
18994 }
18995
18996 case DMAPMIDID:
18997 {
18998 int32_t ID = ri->d[rINDEX] / 10000;
18999
19000 if(BC::checkDMapID(ID, "Game->DMapMIDI") == SH::_NoError)
19001 {
19002 // Based on play_DmapMusic
19003 switch(value / 10000)
19004 {
19005 case -6:
19006 DMaps[ID].midi = 2;
19007 break; // Dungeon
19008
19009 case -3:
19010 DMaps[ID].midi = 3;
19011 break; // Level 9
19012
19013 case -2:
19014 DMaps[ID].midi = 1;
19015 break; // Overworld
19016
19017 case 0:
19018 DMaps[ID].midi = 0;
19019 break; // None
19020
19021 default:
19022 DMaps[ID].midi = value / 10000 + 3;
19023 }
19024 }
19025
19026 break;
19027 }
19028
19029 ///----------------------------------------------------------------------------------------------------//
19030 //Screen->ComboX
19031 case COMBODD:
19032 {
19033 120341 int32_t pos = (ri->d[rINDEX])/10000;
19034 120341 int32_t val = (value/10000);
19035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120341 times.
120341 if ( ((unsigned) pos) > 175 )
19036 {
19037 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboD[]\n", pos);
19038 }
19039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120341 times.
120341 else if ( ((unsigned) val) >= MAXCOMBOS )
19040 {
19041 Z_scripterrlog("Invalid combo ID %d used to write to Screen->ComboD[]\n", val);
19042 }
19043 else
19044 {
19045 120341 screen_combo_modify_preroutine(tmpscr,pos);
19046 120341 tmpscr->data[pos]=(val);
19047 120341 screen_combo_modify_postroutine(tmpscr,pos);
19048 }
19049 }
19050 120341 break;
19051
19052 case COMBOCD:
19053 {
19054 6481 int32_t pos = (ri->d[rINDEX])/10000;
19055 6481 int32_t val = (value/10000); //cset
19056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6481 times.
6481 if ( ((unsigned) pos) > 175 )
19057 {
19058 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboC[]\n", pos);
19059 }
19060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6481 times.
6481 else if ( ((unsigned) val) >= 15 )
19061 {
19062 Z_scripterrlog("Invalid CSet ID %d used to write to Screen->ComboC[]\n", val);
19063 }
19064 else
19065 {
19066 6481 screen_combo_modify_preroutine(tmpscr,pos);
19067 6481 tmpscr->cset[pos]=(val)&15;
19068 6481 screen_combo_modify_postroutine(tmpscr,pos);
19069 }
19070 }
19071 6481 break;
19072
19073 case COMBOFD:
19074 {
19075 int32_t pos = (ri->d[rINDEX])/10000;
19076 int32_t val = (value/10000); //flag
19077 if ( ((unsigned) pos) > 175 )
19078 {
19079 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboF[]\n", pos);
19080 }
19081 else if ( ((unsigned) val) >= 256 )
19082 {
19083 Z_scripterrlog("Invalid Flag ID %d used to write to Screen->ComboF[]\n", val);
19084 }
19085
19086 else
19087 tmpscr->sflag[pos]=(val);
19088 }
19089 break;
19090
19091 case COMBOTD:
19092 {
19093 3560 int32_t pos = (ri->d[rINDEX])/10000;
19094 3560 int32_t val = (value/10000); //type
19095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3560 times.
3560 if ( ((unsigned) pos) > 175 )
19096 {
19097 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboT[]\n", pos);
19098 }
19099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3560 times.
3560 else if ( ((unsigned) val) >= 256 )
19100 {
19101 Z_scripterrlog("Invalid Flag ID %d used to write to Screen->ComboT[]\n", val);
19102 }
19103 else
19104 {
19105 3560 auto cid = tmpscr->data[pos];
19106 3560 screen_combo_modify_pre(cid);
19107 3560 combobuf[cid].type=val;
19108 3560 screen_combo_modify_post(cid);
19109 }
19110 }
19111 3560 break;
19112
19113 case COMBOID:
19114 {
19115 int32_t pos = (ri->d[rINDEX])/10000;
19116 int32_t val = (value/10000); //iflag
19117 if ( ((unsigned) pos) > 175 )
19118 {
19119 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboI[]\n", pos);
19120 }
19121 else if ( ((unsigned) val) >= 256 )
19122 {
19123 Z_scripterrlog("Invalid Flag ID %d used to write to Screen->ComboI[]\n", val);
19124 }
19125
19126 else
19127 combobuf[tmpscr->data[pos]].flag=val;
19128 }
19129 break;
19130
19131 case COMBOSD:
19132 {
19133 81346 int32_t pos = (ri->d[rINDEX])/10000;
19134 81346 int32_t val = (value/10000); //iflag
19135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81346 times.
81346 if ( ((unsigned) pos) > 175 )
19136 {
19137 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboS[]\n", pos);
19138 }
19139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81346 times.
81346 else if ( ((unsigned) val) >= 16 )//solidity 1, 2, 4, 8 max 15
19140 {
19141 Z_scripterrlog("Invalid Flag ID %d used to write to Screen->ComboS[]\n", val);
19142 }
19143 else
19144 {
19145 81346 combobuf[tmpscr->data[pos]].walk &= ~0x0F;
19146 81346 combobuf[tmpscr->data[pos]].walk |= (val)&0x0F;
19147 }
19148 }
19149 81346 break;
19150
19151 case COMBOED:
19152 {
19153 int32_t pos = (ri->d[rINDEX])/10000;
19154 int32_t val = (value/10000); //iflag
19155 if ( ((unsigned) pos) > 175 )
19156 {
19157 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboE[]\n", pos);
19158 }
19159 else if ( ((unsigned) val) >= 16 )//solidity 1, 2, 4, 8 max 15
19160 {
19161 Z_scripterrlog("Invalid Flag ID %d used to write to Screen->ComboE[]\n", val);
19162 }
19163 else
19164 {
19165 combobuf[tmpscr->data[pos]].walk &= ~0xF0;
19166 combobuf[tmpscr->data[pos]].walk |= ((val)&0x0F)<<4;
19167 }
19168 }
19169 break;
19170
19171 ///----------------------------------------------------------------------------------------------------//
19172 //Game->SetComboX
19173 case COMBODDM:
19174 {
19175 5356632 int32_t pos = (ri->d[rINDEX])/10000;
19176 5356632 int32_t sc = (ri->d[rEXP1]/10000);
19177 5356632 int32_t m = (ri->d[rINDEX2]/10000)-1;
19178
2/2
✓ Branch 0 taken 5340616 times.
✓ Branch 1 taken 16016 times.
5356632 int32_t scr = zc_max(m*MAPSCRS+sc,0);
19179 5356632 int32_t layr = whichlayer(scr);
19180
19181 //if(!(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)) break;
19182
19183
2/4
✓ Branch 0 taken 5356632 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5356632 times.
5356632 if(pos < 0 || pos >= 176)
19184 {
19185 Z_scripterrlog("Invalid combo position (%d) passed to SetComboData", pos);
19186 break;
19187 }
19188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5356632 times.
5356632 if(scr < 0)
19189 {
19190 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboData", scr);
19191 break;
19192 }
19193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5356632 times.
5356632 if(sc >= MAPSCRS)
19194 {
19195 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboData", sc);
19196 break;
19197 }
19198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5356632 times.
5356632 if(unsigned(m) >= map_count)
19199 {
19200 Z_scripterrlog("Invalid Map ID (%d) passed to SetComboData", m);
19201 break;
19202 }
19203 5356632 int32_t combo = vbound(value/10000,0,MAXCOMBOS);
19204
2/2
✓ Branch 0 taken 5356419 times.
✓ Branch 1 taken 213 times.
5356632 if(scr==(currmap*MAPSCRS+currscr))
19205 {
19206 213 screen_combo_modify_preroutine(tmpscr,pos);
19207
19208 213 }
19209
19210 5356632 TheMaps[scr].data[pos]=combo;
19211
19212
2/2
✓ Branch 0 taken 5356419 times.
✓ Branch 1 taken 213 times.
5356632 if(scr==(currmap*MAPSCRS+currscr))
19213 {
19214 213 tmpscr->data[pos] = combo;
19215 213 screen_combo_modify_postroutine(tmpscr,pos);
19216 //Start the script for the new combo
19217 213 int index = get_combopos_ref(pos, 0);
19218 213 FFCore.reset_script_engine_data(ScriptType::Combo, index);
19219 //Not ure if combodata arrays clean themselves up, or leak. -Z
19220 //Not sure if this could result in stack corruption.
19221 213 }
19222
19223
2/2
✓ Branch 0 taken 5350083 times.
✓ Branch 1 taken 6549 times.
5356632 if(layr>-1)
19224 {
19225 6549 tmpscr2[layr].data[pos]=combo;
19226 6549 int index = get_combopos_ref(pos, layr + 1);
19227 6549 FFCore.reset_script_engine_data(ScriptType::Combo, index);
19228 6549 }
19229 }
19230 5356632 break;
19231
19232 case COMBOCDM:
19233 {
19234 5344380 int32_t pos = (ri->d[rINDEX])/10000;
19235 5344380 int32_t sc = (ri->d[rEXP1]/10000);
19236 5344380 int32_t m = (ri->d[rINDEX2]/10000)-1;
19237
2/2
✓ Branch 0 taken 5328364 times.
✓ Branch 1 taken 16016 times.
5344380 int32_t scr = zc_max(m*MAPSCRS+sc,0);
19238
19239 //if(!(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)) break;
19240
19241
2/4
✓ Branch 0 taken 5344380 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5344380 times.
5344380 if(pos < 0 || pos >= 176)
19242 {
19243 Z_scripterrlog("Invalid combo position (%d) passed to SetComboCSet", pos);
19244 break;
19245 }
19246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5344380 times.
5344380 if(scr < 0)
19247 {
19248 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboCSet", scr);
19249 break;
19250 }
19251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5344380 times.
5344380 if(sc >= MAPSCRS)
19252 {
19253 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboCSet", sc);
19254 break;
19255 }
19256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5344380 times.
5344380 if(unsigned(m) >= map_count)
19257 {
19258 Z_scripterrlog("Invalid Map ID (%d) passed to SetComboCSet", m);
19259 break;
19260 }
19261
19262 5344380 TheMaps[scr].cset[pos]=(value/10000)&15;
19263
19264
2/2
✓ Branch 0 taken 5344340 times.
✓ Branch 1 taken 40 times.
5344380 if(scr==(currmap*MAPSCRS+currscr))
19265 40 tmpscr->cset[pos] = value/10000;
19266
19267 5344380 int32_t layr = whichlayer(scr);
19268
19269
2/2
✓ Branch 0 taken 5341338 times.
✓ Branch 1 taken 3042 times.
5344380 if(layr>-1)
19270 3042 tmpscr2[layr].cset[pos]=(value/10000)&15;
19271 }
19272 5344380 break;
19273
19274 case COMBOFDM:
19275 {
19276 32221 int32_t pos = (ri->d[rINDEX])/10000;
19277 32221 int32_t sc = (ri->d[rEXP1]/10000);
19278 32221 int32_t m = (ri->d[rINDEX2]/10000)-1;
19279
1/2
✓ Branch 0 taken 32221 times.
✗ Branch 1 not taken.
32221 int32_t scr = zc_max(m*MAPSCRS+sc,0);
19280
19281 //if(!(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)) break;
19282
19283
2/4
✓ Branch 0 taken 32221 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32221 times.
32221 if(pos < 0 || pos >= 176)
19284 {
19285 Z_scripterrlog("Invalid combo position (%d) passed to SetComboFlag", pos);
19286 break;
19287 }
19288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32221 times.
32221 if(scr < 0)
19289 {
19290 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboFlag", scr);
19291 break;
19292 }
19293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32221 times.
32221 if(sc >= MAPSCRS)
19294 {
19295 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboFlag", sc);
19296 break;
19297 }
19298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32221 times.
32221 if(unsigned(m) >= map_count)
19299 {
19300 Z_scripterrlog("Invalid Map ID (%d) passed to SetComboFlag", m);
19301 break;
19302 }
19303
19304 32221 TheMaps[scr].sflag[pos]=value/10000;
19305
19306
2/2
✓ Branch 0 taken 32153 times.
✓ Branch 1 taken 68 times.
32221 if(scr==(currmap*MAPSCRS+currscr))
19307 68 tmpscr->sflag[pos] = value/10000;
19308
19309 32221 int32_t layr = whichlayer(scr);
19310
19311
2/2
✓ Branch 0 taken 32210 times.
✓ Branch 1 taken 11 times.
32221 if(layr>-1)
19312 11 tmpscr2[layr].sflag[pos]=value/10000;
19313 }
19314 32221 break;
19315
19316 case COMBOTDM:
19317 {
19318 760 int32_t pos = (ri->d[rINDEX])/10000;
19319 760 int32_t sc = (ri->d[rEXP1]/10000);
19320 760 int32_t m = (ri->d[rINDEX2]/10000)-1;
19321
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 int32_t scr = zc_max(m*MAPSCRS+sc,0);
19322
19323 //if(!(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count))
19324 // break;
19325
19326
2/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 760 times.
760 if(pos < 0 || pos >= 176)
19327 {
19328 Z_scripterrlog("Invalid combo position (%d) passed to SetComboType", pos);
19329 break;
19330 }
19331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(scr < 0)
19332 {
19333 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboType", scr);
19334 break;
19335 }
19336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(sc >= MAPSCRS)
19337 {
19338 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboType", sc);
19339 break;
19340 }
19341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(unsigned(m) >= map_count)
19342 {
19343 Z_scripterrlog("Invalid Map ID (%d) passed to SetComboType", m);
19344 break;
19345 }
19346
19347 760 int32_t cdata = TheMaps[scr].data[pos];
19348 760 screen_combo_modify_pre(cdata);
19349 760 combobuf[cdata].type=value/10000;
19350 760 screen_combo_modify_post(cdata);
19351 }
19352 760 break;
19353
19354 case COMBOIDM:
19355 {
19356 int32_t pos = (ri->d[rINDEX])/10000;
19357 int32_t sc = (ri->d[rEXP1]/10000);
19358 int32_t m = (ri->d[rINDEX2]/10000)-1;
19359 int32_t scr = zc_max(m*MAPSCRS+sc,0);
19360
19361 //if(!(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count))
19362 // break;
19363
19364 if(pos < 0 || pos >= 176)
19365 {
19366 Z_scripterrlog("Invalid combo position (%d) passed to GetComboInherentFlag", pos);
19367 break;
19368 }
19369 if(scr < 0)
19370 {
19371 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboInherentFlag", scr);
19372 break;
19373 }
19374 if(sc >= MAPSCRS)
19375 {
19376 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboInherentFlag", sc);
19377 break;
19378 }
19379 if(unsigned(m) >= map_count)
19380 {
19381 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboInherentFlag", m);
19382 break;
19383 }
19384
19385 combobuf[TheMaps[scr].data[pos]].flag=value/10000;
19386 }
19387 break;
19388
19389 case COMBOSDM:
19390 {
19391 //This is how it was in 2.50.1-2
19392 int32_t pos = (ri->d[rINDEX])/10000;
19393 int32_t scr = (ri->d[rINDEX2]/10000)*MAPSCRS+(ri->d[rEXP1]/10000);
19394 //This (below) us the precise code from 2.50.1 (?)
19395 //int32_t scr = zc_max((ri->d[rINDEX2]/10000)*MAPSCRS+(ri->d[rEXP1]/10000),0); //Not below 0.
19396
19397 //if(pos < 0 || pos >= 176 || scr < 0) break;
19398 if(pos < 0 || pos >= 176)
19399 {
19400 Z_scripterrlog("Invalid combo position (%d) passed to GetSolid", pos);
19401 break;
19402 }
19403 if(scr < 0)
19404 {
19405 Z_scripterrlog("Invalid MapScreen ID (%d) passed to GetSolid", scr);
19406 break;
19407 }
19408 combobuf[TheMaps[scr].data[pos]].walk &= ~0x0F;
19409 combobuf[TheMaps[scr].data[pos]].walk |= (value/10000)&15;
19410 }
19411 break;
19412
19413 ///----------------------------------------------------------------------------------------------------//
19414 //Screen Variables
19415
19416 #define SET_SCREENDATA_VAR_INT32(member, str) \
19417 { \
19418 tmpscr->member = vbound((value / 10000),-214747,214747); \
19419 } \
19420
19421 #define SET_SCREENDATA_VAR_INT16(member, str) \
19422 { \
19423 tmpscr->member = vbound((value / 10000),0,32767); \
19424 } \
19425
19426 #define SET_SCREENDATA_VAR_BYTE(member, str) \
19427 { \
19428 tmpscr->member = vbound((value / 10000),0,255); \
19429 } \
19430
19431 #define SET_SCREENDATA_VAR_INDEX32(member, str, indexbound) \
19432 { \
19433 int32_t indx = ri->d[rINDEX] / 10000; \
19434 tmpscr->member[indx] = vbound((value / 10000),-214747,214747); \
19435 } \
19436
19437 #define SET_SCREENDATA_VAR_INDEX16(member, str, indexbound) \
19438 { \
19439 int32_t indx = ri->d[rINDEX] / 10000; \
19440 tmpscr->member[indx] = vbound((value / 10000),-32767,32767); \
19441 } \
19442
19443 #define SET_SCREENDATA_BYTE_INDEX(member, str, indexbound) \
19444 { \
19445 int32_t indx = ri->d[rINDEX] / 10000; \
19446 tmpscr->member[indx] = vbound((value / 10000),0,255); \
19447 }
19448 #define SET_SCREENDATA_LAYER_INDEX(member, str, indexbound) \
19449 { \
19450 int32_t indx = ri->d[rINDEX] / 10000; \
19451 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
19452 if(indx < 1 || indx > indexbound ) \
19453 { \
19454 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
19455 } \
19456 else tmpscr->member[indx-1] = vbound((value / 10000),0,255); \
19457 }
19458 ///max screen id is higher! vbound properly... -Z
19459 #define SET_SCREENDATA_LAYERSCREEN_INDEX(member, str, indexbound) \
19460 { \
19461 int32_t indx = ri->d[rINDEX] / 10000; \
19462 int32_t scrn_id = value/10000; \
19463 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
19464 if(indx < 1 || indx > indexbound ) \
19465 { \
19466 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
19467 } \
19468 else if ( scrn_id > MAPSCRS ) \
19469 { \
19470 Z_scripterrlog("Script attempted to use a mapdata->LayerScreen[%d].\n",scrn_id); \
19471 Z_scripterrlog("Valid Screen values are (0) through (%d).\n",MAPSCRS); \
19472 } \
19473 else tmpscr->member[indx-1] = vbound((scrn_id),0,MAPSCRS); \
19474 }
19475
19476 #define SET_SCREENDATA_FLAG(member, str) \
19477 { \
19478 int32_t flag = (value/10000); \
19479 if ( flag != 0 ) \
19480 { \
19481 tmpscr->member|=flag; \
19482 } \
19483 else tmpscr->.member|= ~flag; \
19484 } \
19485
19486 #define SET_SCREENDATA_BOOL_INDEX(member, str, indexbound) \
19487 { \
19488 int32_t indx = ri->d[rINDEX] / 10000; \
19489 if(indx < 0 || indx > indexbound ) \
19490 { \
19491 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", (indx), str); \
19492 break; \
19493 } \
19494 tmpscr->member[indx] =( (value/10000) ? 1 : 0 ); \
19495 }
19496
19497 #define SET_FFC_BOOL_INDEX(member, str, indexbound) \
19498 { \
19499 int32_t indx = ri->d[rINDEX] / 10000; \
19500 if(indx < 0 || indx > indexbound ) \
19501 { \
19502 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", (indx), str); \
19503 break; \
19504 } \
19505 tmpscr->ffcs[indx].member =( (value/10000) ? 1 : 0 ); \
19506 }
19507
19508
19509 case SCREENDATAVALID: SET_SCREENDATA_VAR_BYTE(valid, "Valid"); break; //b
19510 case SCREENDATAGUY: SET_SCREENDATA_VAR_BYTE(guy, "Guy"); break; //b
19511 case SCREENDATASTRING: SET_SCREENDATA_VAR_INT32(str, "String"); break; //w
19512 case SCREENDATAROOM: SET_SCREENDATA_VAR_BYTE(room, "RoomType"); break; //b
19513 case SCREENDATAITEM:
19514 {
19515 auto v = vbound((value / 10000),-1,255);
19516 if(v > -1)
19517 tmpscr->item = v;
19518 tmpscr->hasitem = v > -1;
19519 break;
19520 }
19521 case SCREENDATAHASITEM: SET_SCREENDATA_VAR_BYTE(hasitem, "HasItem"); break; //b
19522 case SCREENDATATILEWARPTYPE: SET_SCREENDATA_BYTE_INDEX(tilewarptype, "TileWarpType", 3); break; //b, 4 of these
19523 //case SCREENDATATILEWARPOVFLAGS: SET_SCREENDATA_VAR_BYTE(tilewarpoverlayflags, "TileWarpOverlayFlags"); break; //b, tilewarpoverlayflags
19524 case SCREENDATADOORCOMBOSET: SET_SCREENDATA_VAR_INT32(door_combo_set, "DoorComboSet"); break; //w
19525 case SCREENDATAWARPRETX: SET_SCREENDATA_BYTE_INDEX(warpreturnx, "WarpReturnX", 3); break; //b, 4 of these
19526 case SCREENDATAWARPRETY: SET_SCREENDATA_BYTE_INDEX(warpreturny, "WarpReturnY", 3); break; //b, 4 of these
19527 case SCREENDATAWARPRETURNC: SET_SCREENDATA_VAR_INT32(warpreturnc, "WarpReturnC"); break; //w
19528 case SCREENDATASTAIRX: SET_SCREENDATA_VAR_BYTE(stairx, "StairsX"); break; //b
19529 case SCREENDATASTAIRY: SET_SCREENDATA_VAR_BYTE(stairy, "StairsY"); break; //b
19530 case SCREENDATAITEMX: SET_SCREENDATA_VAR_BYTE(itemx, "ItemX"); break; //itemx
19531 case SCREENDATAITEMY: SET_SCREENDATA_VAR_BYTE(itemy, "ItemY"); break; //itemy
19532 case SCREENDATACOLOUR: SET_SCREENDATA_VAR_INT32(color, "CSet"); break; //w
19533 case SCREENDATAENEMYFLAGS: SET_SCREENDATA_VAR_BYTE(enemyflags, "EnemyFlags"); break; //b
19534 case SCREENDATADOOR: SET_SCREENDATA_BYTE_INDEX(door, "Door", 3); break; //b, 4 of these
19535 case SCREENDATATILEWARPDMAP: SET_SCREENDATA_VAR_INDEX32(tilewarpdmap, "TileWarpDMap", 3); break; //w, 4 of these
19536 case SCREENDATATILEWARPSCREEN: SET_SCREENDATA_BYTE_INDEX(tilewarpscr, "TileWarpScreen", 3); break; //b, 4 of these
19537 case SCREENDATAEXITDIR: SET_SCREENDATA_VAR_BYTE(exitdir, "ExitDir"); break; //b
19538 case SCREENDATAENEMY:
19539 {
19540 int32_t indx = ri->d[rINDEX] / 10000;
19541 int32_t enemyid = value/10000;
19542 if ( ((unsigned)enemyid) > MAXGUYS )
19543 {
19544 Z_scripterrlog("Invaid enemy ID (%d) passed to Screen->%s.", enemyid,"Enemy[]"); \
19545 break;
19546 }
19547 if(unsigned(indx) > 9)
19548 {
19549 Z_scripterrlog("Invalid index (%d) used for Screen->Enemy[]", indx);
19550 break;
19551 }
19552 tmpscr->enemy[indx] = enemyid;
19553 break;
19554 }
19555 //case SCREENDATAENEMY: SET_SCREENDATA_VAR_INDEX32(enemy, "Enemy", 9); break; //w, 10 of these
19556 case SCREENDATAPATTERN: SET_SCREENDATA_VAR_BYTE(pattern, "Pattern"); break; //b
19557 case SCREENDATASIDEWARPTYPE: SET_SCREENDATA_BYTE_INDEX(sidewarptype, "SideWarpType", 3); break; //b, 4 of these
19558 //case SCREENDATASIDEWARPOVFLAGS: SET_SCREENDATA_VAR_BYTE(sidewarpoverlayflags, "SideWarpOverlayFlags"); break; //b
19559 case SCREENDATAWARPARRIVALX: SET_SCREENDATA_VAR_BYTE(warparrivalx, "WarpArrivalX"); break; //b
19560 case SCREENDATAWARPARRIVALY: SET_SCREENDATA_VAR_BYTE(warparrivaly, "WarpArrivalY"); break; //b
19561 case SCREENDATAPATH: SET_SCREENDATA_BYTE_INDEX(path, "MazePath", 3); break; //b, 4 of these
19562 case SCREENDATASIDEWARPSC: SET_SCREENDATA_BYTE_INDEX(sidewarpscr, "SideWarpScreen", 3); break; //b, 4 of these
19563 case SCREENDATASIDEWARPDMAP: SET_SCREENDATA_VAR_INDEX32(sidewarpdmap, "SideWarpDMap", 3); break; //w, 4 of these
19564 case SCREENDATASIDEWARPINDEX: SET_SCREENDATA_VAR_BYTE(sidewarpindex, "SideWarpIndex"); break; //b
19565 case SCREENDATAUNDERCOMBO: SET_SCREENDATA_VAR_INT32(undercombo, "Undercombo"); break; //w
19566 case SCREENDATAUNDERCSET: SET_SCREENDATA_VAR_BYTE(undercset, "UnderCSet"); break; //b
19567 case SCREENDATACATCHALL: SET_SCREENDATA_VAR_INT32(catchall, "Catchall"); break; //W
19568
19569 case SCREENDATACSENSITIVE: SET_SCREENDATA_VAR_BYTE(csensitive, "CSensitive"); break; //B
19570 case SCREENDATANORESET: SET_SCREENDATA_VAR_INT32(noreset, "NoReset"); break; //W
19571 case SCREENDATANOCARRY: SET_SCREENDATA_VAR_INT32(nocarry, "NoCarry"); break; //W
19572 case SCREENDATALAYERMAP: SET_SCREENDATA_LAYER_INDEX(layermap, "LayerMap", 5); break; //B, 6 OF THESE
19573 case SCREENDATALAYERSCREEN: SET_SCREENDATA_LAYERSCREEN_INDEX(layerscreen, "LayerScreen", 5); break; //B, 6 OF THESE
19574 case SCREENDATALAYEROPACITY: SET_SCREENDATA_LAYER_INDEX(layeropacity, "LayerOpacity", 5); break; //B, 6 OF THESE
19575 case SCREENDATALAYERINVIS:
19576 {
19577 int32_t indx = ri->d[rINDEX] / 10000;
19578 if(indx < 0 || indx > 6 )
19579 {
19580 Z_scripterrlog("Invalid Index passed to Screen->LayerInvisible[]: %d\n", indx);
19581 }
19582 else
19583 {
19584 if(value)
19585 tmpscr->hidelayers |= (1<<indx);
19586 else
19587 tmpscr->hidelayers &= ~(1<<indx);
19588 }
19589 break;
19590 }
19591 case SCREENDATASCRIPTDRAWS:
19592 {
19593 int32_t indx = ri->d[rINDEX] / 10000;
19594 if(indx < 0 || indx > 7 )
19595 {
19596 Z_scripterrlog("Invalid Index passed to Screen->HideScriptLayer[]: %d\n", indx);
19597 }
19598 else
19599 {
19600 if(value)
19601 tmpscr->hidescriptlayers &= ~(1<<indx);
19602 else
19603 tmpscr->hidescriptlayers |= (1<<indx);
19604 }
19605 break;
19606 }
19607
19608 case SCREENDATATILEWARPOVFLAGS:
19609 {
19610 int32_t indx = ri->d[rINDEX] / 10000;
19611 if ( ((unsigned)indx) > 3 )
19612 {
19613 Z_scripterrlog("Invalid index passed to TileWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
19614 }
19615 else
19616 {
19617 if ( value ) tmpscr->tilewarpoverlayflags |= (1<<indx);
19618 else tmpscr->tilewarpoverlayflags &= ~(1<<indx);
19619 }
19620 break;
19621 }
19622
19623 case SCREENDATASIDEWARPOVFLAGS:
19624 {
19625 int32_t indx = ri->d[rINDEX] / 10000;
19626 if ( ((unsigned)indx) > 3 )
19627 {
19628 Z_scripterrlog("Invalid index passed to SideWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
19629 }
19630 else
19631 {
19632 if ( value ) tmpscr->sidewarpoverlayflags |= (1<<indx);
19633 else tmpscr->sidewarpoverlayflags &= ~(1<<indx);
19634 }
19635 break;
19636 }
19637
19638 case SCREENDATATIMEDWARPTICS: SET_SCREENDATA_VAR_INT32(timedwarptics, "TimedWarpTimer"); break; //W
19639 case SCREENDATANEXTMAP: SET_SCREENDATA_VAR_BYTE(nextmap, "NextMap"); break; //B
19640 case SCREENDATANEXTSCREEN: SET_SCREENDATA_VAR_BYTE(nextscr, "NextScreen"); break; //B
19641 128 case SCREENDATASECRETCOMBO: SET_SCREENDATA_VAR_INDEX32(secretcombo, "SecretCombo", 127); break; //W, 128 OF THESE
19642 128 case SCREENDATASECRETCSET: SET_SCREENDATA_BYTE_INDEX(secretcset, "SecretCSet", 127); break; //B, 128 OF THESE
19643 128 case SCREENDATASECRETFLAG: SET_SCREENDATA_BYTE_INDEX(secretflag, "SecretFlags", 127); break; //B, 128 OF THESE
19644 case SCREENDATAVIEWX: break;//SET_SCREENDATA_VAR_INT32(viewX, "ViewX"); break; //W
19645 case SCREENDATAVIEWY: break;//SET_SCREENDATA_VAR_INT32(viewY, "ViewY"); break; //W
19646 case SCREENDATASCREENWIDTH: break;//SET_SCREENDATA_VAR_BYTE(scrWidth, "Width"); break; //B
19647 case SCREENDATASCREENHEIGHT: break;//SET_SCREENDATA_VAR_BYTE(scrHeight, "Height"); break; //B
19648 case SCREENDATAENTRYX:
19649 {
19650 5 int32_t newx = vbound((value/10000),0,255);
19651 5 tmpscr->entry_x = newx;
19652
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if ( get_qr(qr_WRITE_ENTRYPOINTS_AFFECTS_HEROCLASS) )
19653 {
19654 Hero.respawn_x = (zfix)(newx);
19655 }
19656 5 break;
19657 }
19658 case SCREENDATAENTRYY:
19659 {
19660
19661 5 int32_t newy = vbound((value/10000),0,175);
19662 5 tmpscr->entry_y = newy;
19663
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if ( get_qr(qr_WRITE_ENTRYPOINTS_AFFECTS_HEROCLASS) )
19664 {
19665 Hero.respawn_y = (zfix)(newy);
19666 }
19667 5 break; //B
19668 }
19669
19670 case SCREENDATANUMFF:
19671 {
19672 break;
19673 }
19674
19675 case SCREENDATAFFINITIALISED:
19676 {
19677 int32_t indx = ri->d[rINDEX] / 10000;
19678 if (indx < 0 || indx > MAXFFCS-1)
19679 {
19680 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", (indx), "FFCRunning");
19681 break;
19682 }
19683 get_script_engine_data(ScriptType::FFC, indx).initialized = (value/10000) ? true : false;
19684 }
19685 break;
19686
19687 case SCREENDATASCRIPTENTRY: SET_SCREENDATA_VAR_INT32(script_entry, "ScriptEntry"); break; //W
19688 case SCREENDATASCRIPTOCCUPANCY: SET_SCREENDATA_VAR_INT32(script_occupancy, "ScriptOccupancy"); break;//W
19689 case SCREENDATASCRIPTEXIT: SET_SCREENDATA_VAR_INT32(script_exit, "ExitScript"); break; //W
19690 case SCREENDATAOCEANSFX:
19691 {
19692 int32_t v = vbound(value/10000, 0, 255);
19693 if(tmpscr->oceansfx != v)
19694 {
19695 stop_sfx(tmpscr->oceansfx);
19696 tmpscr->oceansfx = v;
19697 cont_sfx(tmpscr->oceansfx);
19698 }
19699 break;
19700 }
19701 case SCREENDATABOSSSFX: SET_SCREENDATA_VAR_BYTE(bosssfx, "BossSFX"); break; //B
19702 case SCREENDATASECRETSFX: SET_SCREENDATA_VAR_BYTE(secretsfx, "SecretSFX"); break; //B
19703 case SCREENDATAHOLDUPSFX: SET_SCREENDATA_VAR_BYTE(holdupsfx, "ItemSFX"); break; //B
19704 case SCREENDATASCREENMIDI:
19705 {
19706 tmpscr->screen_midi = vbound((value / 10000)-(MIDIOFFSET_MAPSCR-MIDIOFFSET_ZSCRIPT),-1,32767);
19707 break;
19708 }
19709 case SCREENDATALENSLAYER: SET_SCREENDATA_VAR_BYTE(lens_layer, "LensLayer"); break; //B, OLD QUESTS ONLY?
19710
19711 case SCREENSIDEWARPID:
19712 {
19713 int32_t indx = ri->d[rINDEX] / 10000; //dir
19714
19715 int32_t new_warp_return = vbound((value / 10000),-1,3); //none, A, B, C, D
19716 if(new_warp_return == -1)
19717 {
19718 tmpscr->flags2 &= ~(1<<indx); //Unset the "Enabled" flag for this dir
19719 tmpscr->sidewarpindex &= ~(3<<(2*indx)); //Clear the dir as well.
19720 }
19721 else
19722 {
19723 tmpscr->flags2 |= 1<<indx; //Set the "Enabled" flag for this dir
19724 tmpscr->sidewarpindex &= ~(3<<(2*indx)); //Clear the dir bits
19725 tmpscr->sidewarpindex |= (new_warp_return<<(2*indx)); //Set the new dir
19726 }
19727
19728 break;
19729 }
19730
19731 case SCREENDATATWARPRETSQR:
19732 {
19733 int32_t indx = ri->d[rINDEX] / 10000;
19734 if ( ((unsigned)indx) > 3)
19735 {
19736 Z_scripterrlog("Invalid Array Index passed to Screen->TileWarpReturnSquare[]: %d\n", indx);
19737 }
19738 else
19739 {
19740 int32_t wrindex = vbound(value/10000, 0, 3);
19741 tmpscr->warpreturnc = (tmpscr->warpreturnc&~(3<<(indx*2))) | (wrindex<<(indx*2));
19742 }
19743 break;
19744 }
19745
19746 //
19747 case SCREENDATASWARPRETSQR:
19748 {
19749
19750 int32_t indx = ri->d[rINDEX] / 10000;
19751 if ( ((unsigned)indx) > 3)
19752 {
19753 Z_scripterrlog("Invalid Array Index passed to Screen->SideWarpReturnSquare[]: %d\n", indx);
19754 }
19755 else
19756 {
19757 int32_t wrindex = vbound(value/10000, 0, 3);
19758 tmpscr->warpreturnc = (tmpscr->warpreturnc&~(3<<(8+(indx*2)))) | (wrindex<<(8+(indx*2)));
19759 }
19760 break;
19761 }
19762
19763
19764 case SCREENDATAFLAGS:
19765 {
19766 int32_t flagid = (ri->d[rINDEX])/10000;
19767 //bool valtrue = ( value ? 10000 : 0);
19768 switch(flagid)
19769 {
19770 case 0: tmpscr->flags = (value / 10000); break;
19771 case 1: tmpscr->flags2 = (value / 10000); break;
19772 case 2: tmpscr->flags3 = (value / 10000); break;
19773 case 3: tmpscr->flags4 = (value / 10000); break;
19774 case 4: tmpscr->flags5 = (value / 10000); break;
19775 case 5: tmpscr->flags6 = (value / 10000); break;
19776 case 6: tmpscr->flags7 = (value / 10000); break;
19777 case 7: tmpscr->flags8 = (value / 10000); break;
19778 case 8: tmpscr->flags9 = (value / 10000); break;
19779 case 9: tmpscr->flags10 = (value / 10000); break;
19780 default:
19781 {
19782 Z_scripterrlog("Invalid index passed to mapdata->flags[]: %d\n", flagid);
19783 break;
19784
19785 }
19786 }
19787 break;
19788 //GET_SCREENDATA_BYTE_INDEX //B, 11 OF THESE, flags, flags2-flags10
19789 }
19790
19791
19792 //These use the same method as SetScreenD
19793 case SCREENWIDTH:
19794 // FFScript::set_screenWidth(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19795 break;
19796
19797 case SCREENHEIGHT:
19798 // FFScript::set_screenHeight(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19799 break;
19800
19801 case SCREENVIEWX:
19802 // FFScript::set_screenViewX(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19803 break;
19804
19805 case SCREENVIEWY:
19806 // FFScript::set_screenViewY(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19807 break;
19808
19809 case SCREENGUY:
19810 FFScript::set_screenGuy(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19811 break;
19812
19813 case SCREENSTRING:
19814 {
19815 FFScript::set_screenString(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19816 //should this be either
19817 //set_screenString(&TheMaps[((ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)])-1), value/10000);
19818 //or
19819 //set_screenString(&TheMaps[((ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)])-+1), value/10000);
19820 Z_message("Map ref is: %d\n",((ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)));
19821 }
19822 break;
19823
19824 case SCREENROOM:
19825 FFScript::set_screenRoomtype(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19826 break;
19827
19828 case SCREENENTX:
19829 FFScript::set_screenEntryX(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19830 break;
19831
19832 case SCREENENTY:
19833 FFScript::set_screenEntryY(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19834 break;
19835
19836 case SCREENITEM:
19837 FFScript::set_screenitem(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19838 break;
19839
19840 case SCREENUNDCMB:
19841 FFScript::set_screenundercombo(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19842 break;
19843
19844 case SCREENUNDCST:
19845 FFScript::set_screenundercset(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19846 break;
19847
19848 case SCREENCATCH:
19849 FFScript::set_screenatchall(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19850 break;
19851
19852 //These use the method of SetScreenEnemy
19853
19854
19855 //SetScreenLayerOpacity(int32_t map, int32_t scr, int32_t layer, int32_t v)
19856 case SETSCREENLAYOP:
19857 {
19858 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
19859 int32_t scrn = ri->d[rEXP1] / 10000;
19860 int32_t index = ri->d[rINDEX] / 10000;
19861 int32_t nn = ri->d[rEXP2]/10000;
19862
19863 if(BC::checkMapID(map, "Game->SetScreenLayerOpacity(...map...)") != SH::_NoError ||
19864 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenLayerOpacity(...screen...)") != SH::_NoError ||
19865 BC::checkBounds(index, 0, 9, "Game->SetScreenLayerOpacity(...index...)") != SH::_NoError)
19866 return;
19867
19868 FFScript::set_screenlayeropacity(&TheMaps[map * MAPSCRS + scrn], index, nn);
19869 }
19870 break;
19871
19872 case SETSCREENSECCMB:
19873 {
19874 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
19875 int32_t scrn = ri->d[rEXP1] / 10000;
19876 int32_t index = ri->d[rINDEX] / 10000;
19877 int32_t nn = ri->d[rEXP2]/10000;
19878
19879 if(BC::checkMapID(map, "Game->SetScreenSecretCombo(...map...)") != SH::_NoError ||
19880 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenSecretCombo(...screen...)") != SH::_NoError ||
19881 BC::checkBounds(index, 0, 9, "Game->SetScreenSecretCombo(...index...)") != SH::_NoError)
19882 return;
19883
19884 FFScript::set_screensecretcombo(&TheMaps[map * MAPSCRS + scrn], index, nn);
19885 }
19886 break;
19887
19888 case SETSCREENSECCST:
19889 {
19890 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
19891 int32_t scrn = ri->d[rEXP1] / 10000;
19892 int32_t index = ri->d[rINDEX] / 10000;
19893 int32_t nn = ri->d[rEXP2]/10000;
19894
19895 if(BC::checkMapID(map, "Game->SetScreenSecretCSet(...map...)") != SH::_NoError ||
19896 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenSecretCSet(...screen...)") != SH::_NoError ||
19897 BC::checkBounds(index, 0, 9, "Game->SetScreenSecretCSet(...index...)") != SH::_NoError)
19898 return;
19899
19900 FFScript::set_screensecretcset(&TheMaps[map * MAPSCRS + scrn], index, nn);
19901 }
19902 break;
19903
19904 case SETSCREENSECFLG:
19905 {
19906 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
19907 int32_t scrn = ri->d[rEXP1] / 10000;
19908 int32_t index = ri->d[rINDEX] / 10000;
19909 int32_t nn = ri->d[rEXP2]/10000;
19910
19911 if(BC::checkMapID(map, "Game->SetScreenSecretFlag(...map...)") != SH::_NoError ||
19912 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenSecretFlag(...screen...)") != SH::_NoError ||
19913 BC::checkBounds(index, 0, 9, "Game->SetScreenSecretFlag(...index...)") != SH::_NoError)
19914 return;
19915
19916 FFScript::set_screensecretflag(&TheMaps[map * MAPSCRS + scrn], index, nn);
19917 }
19918 break;
19919
19920 case SETSCREENLAYMAP:
19921 {
19922 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
19923 int32_t scrn = ri->d[rEXP1] / 10000;
19924 int32_t index = ri->d[rINDEX] / 10000;
19925 int32_t nn = ri->d[rEXP2]/10000;
19926
19927 if(BC::checkMapID(map, "Game->SetScreenLayerMap(...map...)") != SH::_NoError ||
19928 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenLayerMap(...screen...)") != SH::_NoError ||
19929 BC::checkBounds(index, 0, 9, "Game->SetScreenLayerMap(...index...)") != SH::_NoError)
19930 return;
19931
19932 FFScript::set_screenlayermap(&TheMaps[map * MAPSCRS + scrn], index, nn);
19933 }
19934 break;
19935
19936 case SETSCREENLAYSCR:
19937 {
19938 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
19939 int32_t scrn = ri->d[rEXP1] / 10000;
19940 int32_t index = ri->d[rINDEX] / 10000;
19941 int32_t nn = ri->d[rEXP2]/10000;
19942
19943 if(BC::checkMapID(map, "Game->SetScreenLayerScreen(...map...)") != SH::_NoError ||
19944 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenLayerScreen(...screen...)") != SH::_NoError ||
19945 BC::checkBounds(index, 0, 9, "Game->SetScreenLayerScreen(...index...)") != SH::_NoError)
19946 return;
19947
19948 FFScript::set_screenlayerscreen(&TheMaps[map * MAPSCRS + scrn], index, nn);
19949 }
19950 break;
19951
19952 case SETSCREENPATH:
19953 {
19954 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
19955 int32_t scrn = ri->d[rEXP1] / 10000;
19956 int32_t index = ri->d[rINDEX] / 10000;
19957 int32_t nn = ri->d[rEXP2]/10000;
19958
19959 if(BC::checkMapID(map, "Game->SetScreenPath(...map...)") != SH::_NoError ||
19960 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenPath(...screen...)") != SH::_NoError ||
19961 BC::checkBounds(index, 0, 9, "Game->SetScreenPath(...index...)") != SH::_NoError)
19962 return;
19963
19964 FFScript::set_screenpath(&TheMaps[map * MAPSCRS + scrn], index, nn);
19965 }
19966 break;
19967
19968 case SETSCREENWARPRX:
19969 {
19970 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
19971 int32_t scrn = ri->d[rEXP1] / 10000;
19972 int32_t index = ri->d[rINDEX] / 10000;
19973 int32_t nn = ri->d[rEXP2]/10000;
19974
19975 if(BC::checkMapID(map, "Game->SetScreenWarpReturnX(...map...)") != SH::_NoError ||
19976 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenWarpReturnX(...screen...)") != SH::_NoError ||
19977 BC::checkBounds(index, 0, 9, "Game->SetScreenWarpReturnX(...index...)") != SH::_NoError)
19978 return;
19979
19980 FFScript::set_screenwarpReturnX(&TheMaps[map * MAPSCRS + scrn], index, nn);
19981 }
19982 break;
19983
19984 case SETSCREENWARPRY:
19985 {
19986 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
19987 int32_t scrn = ri->d[rEXP1] / 10000;
19988 int32_t index = ri->d[rINDEX] / 10000;
19989 int32_t nn = ri->d[rEXP2]/10000;
19990
19991 if(BC::checkMapID(map, "Game->SetScreenWarpReturnY(...map...)") != SH::_NoError ||
19992 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenWarpReturnY(...screen...)") != SH::_NoError ||
19993 BC::checkBounds(index, 0, 9, "Game->SetScreenWarpReturnY(...index...)") != SH::_NoError)
19994 return;
19995
19996 FFScript::set_screenwarpReturnY(&TheMaps[map * MAPSCRS + scrn], index, nn);
19997 }
19998 break;
19999
20000 case SDD:
20001 {
20002 {
20003
2/2
✓ Branch 0 taken 14236 times.
✓ Branch 1 taken 41 times.
14277 int32_t di2 = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20004 14277 FFScript::set_screen_d(di2, ri->d[rINDEX]/10000, value);
20005 14277 break;
20006 }
20007 }
20008
20009 case GDD:
20010 al_trace("GDD");
20011 game->global_d[ri->d[rINDEX]/10000]=value;
20012 break;
20013
20014 case SDDD:
20015 27297 FFScript::set_screen_d((ri->d[rINDEX])/10000 + ((get_currdmap())<<7), ri->d[rINDEX2]/10000, value);
20016 27297 break;
20017
20018 case SDDDD:
20019 531 FFScript::set_screen_d(ri->d[rINDEX2]/10000 + ((ri->d[rINDEX]/10000)<<7), ri->d[rEXP1]/10000, value);
20020 531 break;
20021
20022 case SCREENINITD:
20023 tmpscr->screeninitd[ri->d[rINDEX]/10000] = value;
20024 break;
20025
20026 case SCREENSCRIPT:
20027 {
20028 FFScript::deallocateAllArrays(ScriptType::Screen, 0);
20029
20030 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
20031 {
20032 for(int32_t q=0; q<8; q++)
20033 tmpscr->screeninitd[q] = 0;
20034 }
20035 FFCore.ref(ScriptType::Screen, 0).Clear();
20036 tmpscr->script=vbound(value/10000, 0, NUMSCRIPTSCREEN-1);
20037 break;
20038 }
20039
20040 case MAPDATAINITD:
20041 tmpscr->screeninitd[ri->d[rINDEX]/10000]=value;
20042 break;
20043
20044 case SCRDOORD:
20045 4 tmpscr->door[ri->d[rINDEX]/10000]=value/10000;
20046 4 putdoor(scrollbuf,0,ri->d[rINDEX]/10000,value/10000,true,true);
20047 4 break;
20048
20049 case LIT:
20050 900 naturaldark = !value;
20051 900 lighting(false, false);
20052 900 break;
20053
20054 case WAVY:
20055 7214 wavy=value/10000;
20056 7214 break;
20057
20058 case QUAKE:
20059 3579 quakeclk=value/10000;
20060 3579 break;
20061
20062 case ROOMTYPE:
20063 tmpscr->room=value/10000; break; //this probably doesn't work too well...
20064
20065 case ROOMDATA:
20066 11 tmpscr->catchall=value/10000;
20067 11 break;
20068
20069 case PUSHBLOCKLAYER:
20070 mblock2.blockLayer=vbound(value/10000, 0, 6);
20071 break;
20072
20073 case PUSHBLOCKCOMBO:
20074 mblock2.bcombo=value/10000;
20075 break;
20076
20077 case PUSHBLOCKCSET:
20078 mblock2.cs=value/10000;
20079 mblock2.oldcset=value/10000;
20080 break;
20081
20082 case UNDERCOMBO:
20083 tmpscr->undercombo=value/10000;
20084 break;
20085
20086 case UNDERCSET:
20087 tmpscr->undercset=value/10000;
20088 break;
20089
20090
20091 case DEBUGGDR:
20092 {
20093 int32_t a = vbound(ri->d[rINDEX]/10000,0,15);
20094 game->global_d[a] = value / 10000;;
20095 break;
20096 }
20097
20098 case DEBUGSP:
20099 SH::write_stack(ri->sp,vbound((value / 10000),0,MAX_SCRIPT_REGISTERS-1));
20100 break;
20101
20102 case DEBUGREFFFC:
20103 ri->ffcref = vbound((value / 10000),1,MAXFFCS-1);
20104 break;
20105
20106 case DEBUGREFITEM:
20107 ri->itemref = vbound((value / 10000),0,255);
20108 break;
20109
20110 case DEBUGREFITEMDATA:
20111 ri->idata = vbound((value / 10000),0,255);
20112 break;
20113
20114 case DEBUGREFLWEAPON:
20115 ri->lwpn = vbound((value / 10000),0,255);
20116 break;
20117
20118 case DEBUGREFEWEAPON:
20119 ri->ewpn = vbound((value / 10000),0,255);
20120 break;
20121
20122 case DEBUGREFNPC:
20123 ri->guyref = vbound((value / 10000),0,255);
20124 break;
20125
20126
20127 //Game Over Screen
20128 case SETGAMEOVERELEMENT:
20129 {
20130 17 int32_t colour = value/10000;
20131 17 int32_t index = ri->d[rINDEX]/10000;
20132 17 index = vbound(index,0,SAVESC_LAST-1);
20133 // zprint("GameOverScreen Index,Value: %d,%ld/n",index,colour);
20134 17 SetSaveScreenSetting(index,colour);
20135 17 break;
20136 }
20137
20138 case SETGAMEOVERSTRING:
20139 {
20140 int32_t arrayptr = value/10000;
20141 int32_t index = ri->d[rINDEX]/10000;
20142 index = vbound(index,0,SAVESC_END-1);
20143 string filename_str;
20144 ArrayH::getString(arrayptr, filename_str, 73);
20145 ChangeSubscreenText(index,filename_str.c_str());
20146 break;
20147 }
20148
20149 ///----------------------------------------------------------------------------------------------------//
20150 //New Datatype Variables
20151
20152 ///----------------------------------------------------------------------------------------------------//
20153 //spritedata sp-> Variables
20154 case SPRITEDATATILE: SET_SPRITEDATA_VAR_INT(tile, "Tile"); break;
20155 case SPRITEDATAMISC: SET_SPRITEDATA_VAR_BYTE(misc, "Misc"); break;
20156 case SPRITEDATACSETS:
20157 {
20158 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
20159 {
20160 Z_scripterrlog("Invalid Sprite ID passed to spritedata->CSet: %d\n", (ri->spritesref*10000));
20161 }
20162 else
20163 {
20164 wpnsbuf[ri->spritesref].csets &= 0xF0;
20165 wpnsbuf[ri->spritesref].csets |= vbound((value / 10000),0,15);
20166 }
20167 break;
20168 }
20169 case SPRITEDATAFLCSET:
20170 {
20171 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
20172 {
20173 Z_scripterrlog("Invalid Sprite ID passed to spritedata->FlashCSet: %d\n", (ri->spritesref*10000));
20174 }
20175 else
20176 {
20177 wpnsbuf[ri->spritesref].csets &= 0x0F;
20178 wpnsbuf[ri->spritesref].csets |= vbound((value / 10000),0,15)<<4;
20179 }
20180 break;
20181 }
20182 case SPRITEDATAFRAMES: SET_SPRITEDATA_VAR_BYTE(frames, "Frames"); break;
20183 case SPRITEDATASPEED: SET_SPRITEDATA_VAR_BYTE(speed, "Speed"); break;
20184 case SPRITEDATATYPE: SET_SPRITEDATA_VAR_BYTE(type, "Type"); break;
20185 case SPRITEDATAFLAGS:
20186 {
20187 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
20188 {
20189 Z_scripterrlog("Invalid Sprite ID passed to spritedata->Flags[]: %d\n", (ri->spritesref*10000));
20190 break;
20191 }
20192 int32_t index = ri->d[rINDEX]/10000;
20193 if(unsigned(index) >= 5)
20194 {
20195 Z_scripterrlog("Invalid index passed to spritedata->Flags[]: %d\n", index);
20196 break;
20197 }
20198 SETFLAG(wpnsbuf[ri->spritesref].misc, 1<<index, value);
20199 break;
20200 }
20201
20202 ///----------------------------------------------------------------------------------------------------//
20203 //mapdata m-> Variables
20204 //mapdata m-> Variables
20205
20206 #define SET_MAPDATA_VAR_INT32(member, str) \
20207 { \
20208 if (mapscr *m = GetMapscr(ri->mapsref)) \
20209 { \
20210 m->member = vbound((value / 10000),-214747,214747); \
20211 } \
20212 else \
20213 { \
20214 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
20215 } \
20216 break; \
20217 } \
20218
20219 #define SET_MAPDATA_VAR_INT16(member, str) \
20220 { \
20221 if (mapscr *m = GetMapscr(ri->mapsref)) \
20222 { \
20223 m->member = vbound((value / 10000),0,32767); \
20224 } \
20225 else \
20226 { \
20227 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
20228 } \
20229 break; \
20230 } \
20231
20232 #define SET_MAPDATA_VAR_BYTE(member, str) \
20233 { \
20234 if (mapscr *m = GetMapscr(ri->mapsref)) \
20235 { \
20236 m->member = vbound((value / 10000),0,255); \
20237 } \
20238 else \
20239 { \
20240 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
20241 } \
20242 break; \
20243 } \
20244
20245 #define SET_MAPDATA_VAR_INDEX32(member, str, indexbound) \
20246 { \
20247 int32_t indx = ri->d[rINDEX] / 10000; \
20248 if(indx < 0 || indx > indexbound ) \
20249 { \
20250 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
20251 } \
20252 else if (mapscr *m = GetMapscr(ri->mapsref)) \
20253 { \
20254 m->member[indx] = vbound((value / 10000),-214747,214747); \
20255 } \
20256 else \
20257 { \
20258 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
20259 } \
20260 break; \
20261 } \
20262
20263 #define SET_MAPDATA_VAR_INDEX16(member, str, indexbound) \
20264 { \
20265 int32_t indx = ri->d[rINDEX] / 10000; \
20266 if(indx < 0 || indx > indexbound ) \
20267 { \
20268 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
20269 } \
20270 else if (mapscr *m = GetMapscr(ri->mapsref)) \
20271 { \
20272 m->member[indx] = vbound((value / 10000),-32767,32767); \
20273 } \
20274 else \
20275 { \
20276 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
20277 } \
20278 break; \
20279 } \
20280
20281 #define SET_MAPDATA_BYTE_INDEX(member, str, indexbound) \
20282 { \
20283 int32_t indx = ri->d[rINDEX] / 10000; \
20284 if(indx < 0 || indx > indexbound ) \
20285 { \
20286 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
20287 } \
20288 else if (mapscr *m = GetMapscr(ri->mapsref)) \
20289 { \
20290 m->member[indx] = vbound((value / 10000),0,255); \
20291 } \
20292 else \
20293 { \
20294 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
20295 } \
20296 break; \
20297 }\
20298
20299 #define SET_MAPDATA_LAYER_INDEX(member, str, indexbound) \
20300 { \
20301 int32_t indx = ri->d[rINDEX] / 10000; \
20302 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
20303 if(indx < 1 || indx > indexbound ) \
20304 { \
20305 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
20306 } \
20307 else if (mapscr *m = GetMapscr(ri->mapsref)) \
20308 { \
20309 m->member[indx-1] = vbound((value / 10000),0,255); \
20310 } \
20311 else \
20312 { \
20313 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
20314 } \
20315 break; \
20316 } \
20317
20318 #define SET_MAPDATA_LAYERSCREEN_INDEX(member, str, indexbound) \
20319 { \
20320 int32_t indx = ri->d[rINDEX] / 10000; \
20321 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
20322 int32_t scrn_id = value/10000; \
20323 if(indx < 1 || indx > indexbound ) \
20324 { \
20325 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
20326 } \
20327 else if ( scrn_id > MAPSCRS ) \
20328 { \
20329 Z_scripterrlog("Script attempted to use a mapdata->LayerScreen[%d].\n",scrn_id); \
20330 Z_scripterrlog("Valid Screen values are (0) through (%d).\n",MAPSCRS); \
20331 } \
20332 else if (mapscr *m = GetMapscr(ri->mapsref)) \
20333 { \
20334 m->member[indx-1] = vbound((scrn_id),0,MAPSCRS); \
20335 } \
20336 else \
20337 { \
20338 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
20339 } \
20340 break; \
20341 }\
20342
20343 #define SET_MAPDATA_BOOL_INDEX(member, str, indexbound) \
20344 { \
20345 int32_t indx = ri->d[rINDEX] / 10000; \
20346 if(indx < 0 || indx > indexbound ) \
20347 { \
20348 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
20349 } \
20350 else if (mapscr *m = GetMapscr(ri->mapsref)) \
20351 { \
20352 m->member[indx] =( (value/10000) ? 1 : 0 ); \
20353 } \
20354 else \
20355 { \
20356 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
20357 } \
20358 break; \
20359 } \
20360
20361 #define SET_FFC_MAPDATA_BOOL_INDEX(member, str, indexbound) \
20362 { \
20363 int32_t indx = ri->d[rINDEX] / 10000; \
20364 if(indx < 0 || indx > indexbound ) \
20365 { \
20366 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
20367 } \
20368 else if (mapscr *m = GetMapscr(ri->mapsref)) \
20369 { \
20370 m->ffcs[indx].member =( (value/10000) ? 1 : 0 ); \
20371 } \
20372 else \
20373 { \
20374 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
20375 } \
20376 break; \
20377 } \
20378
20379 #define SET_MAPDATA_FLAG(member, str) \
20380 { \
20381 int32_t flag = (value/10000); \
20382 if (mapscr *m = GetMapscr(ri->mapsref)) \
20383 { \
20384 if ( flag != 0 ) \
20385 { \
20386 m->member|=flag; \
20387 } \
20388 else m->.member|= ~flag; \
20389 } \
20390 else \
20391 { \
20392 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
20393 } \
20394 break; \
20395 } \
20396
20397 #define SET_MAPDATA_FFCPOS_INDEX32(member, str, indexbound) \
20398 { \
20399 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
20400 if(indx < 0 || indx > indexbound ) \
20401 { \
20402 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
20403 } \
20404 else if (mapscr *m = GetMapscr(ri->mapsref)) \
20405 { \
20406 m->ffcs[indx].member = zslongToFix(value); \
20407 } \
20408 else \
20409 { \
20410 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
20411 } \
20412 break; \
20413 } \
20414
20415 #define SET_MAPDATA_FFC_INDEX32(member, str, indexbound) \
20416 { \
20417 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
20418 if(indx < 0 || indx > indexbound ) \
20419 { \
20420 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
20421 } \
20422 else if (mapscr *m = GetMapscr(ri->mapsref)) \
20423 { \
20424 m->ffcs[indx].member = value/10000; \
20425 } \
20426 else \
20427 { \
20428 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
20429 } \
20430 break; \
20431 } \
20432
20433 #define SET_MAPDATA_FFC_INDEX_VBOUND(member, str, indexbound, min, max) \
20434 { \
20435 int32_t v = value/10000; \
20436 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
20437 if(indx < 0 || indx > indexbound ) \
20438 { \
20439 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
20440 } \
20441 else if(v < min || v > max ) \
20442 { \
20443 Z_scripterrlog("Invalid value assigned to mapdata->%s[]: %d\n", (indx+1), str); \
20444 } \
20445 else if (mapscr *m = GetMapscr(ri->mapsref)) \
20446 { \
20447 m->ffcs[indx].member = v; \
20448 } \
20449 else \
20450 { \
20451 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
20452 } \
20453 break; \
20454 } \
20455
20456 case MAPDATAVALID: SET_MAPDATA_VAR_BYTE(valid, "Valid"); break; //b
20457 case MAPDATAGUY: SET_MAPDATA_VAR_BYTE(guy, "Guy"); break; //b
20458 case MAPDATASTRING: SET_MAPDATA_VAR_INT32(str, "String"); break; //w
20459 case MAPDATAROOM: SET_MAPDATA_VAR_BYTE(room, "RoomType"); break; //b
20460 case MAPDATAITEM:
20461 {
20462 if (mapscr *m = GetMapscr(ri->mapsref))
20463 {
20464 auto v = vbound((value / 10000),-1,255);
20465 if(v > -1)
20466 m->item = v;
20467 m->hasitem = v > -1;
20468 }
20469 else
20470 {
20471 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Item");
20472 }
20473 break;
20474 }
20475 case MAPDATAHASITEM: SET_MAPDATA_VAR_BYTE(hasitem, "HasItem"); break; //b
20476 case MAPDATATILEWARPTYPE: SET_MAPDATA_BYTE_INDEX(tilewarptype, "TileWarpType", 3); break; //b, 4 of these
20477 //case MAPDATATILEWARPOVFLAGS: SET_MAPDATA_VAR_BYTE(tilewarpoverlayflags, "TileWarpOverlayFlags"); break; //b, tilewarpoverlayflags
20478 case MAPDATADOORCOMBOSET: SET_MAPDATA_VAR_INT32(door_combo_set, "DoorComboSet"); break; //w
20479 case MAPDATAWARPRETX: SET_MAPDATA_BYTE_INDEX(warpreturnx, "WarpReturnX", 3); break; //b, 4 of these
20480 case MAPDATAWARPRETY: SET_MAPDATA_BYTE_INDEX(warpreturny, "WarpReturnY", 3); break; //b, 4 of these
20481 case MAPDATAWARPRETURNC: SET_MAPDATA_VAR_INT32(warpreturnc, "WarpReturnC"); break; //w
20482 case MAPDATASTAIRX: SET_MAPDATA_VAR_BYTE(stairx, "StairsX"); break; //b
20483 case MAPDATASTAIRY: SET_MAPDATA_VAR_BYTE(stairy, "StairsY"); break; //b
20484 case MAPDATAITEMX: SET_MAPDATA_VAR_BYTE(itemx, "ItemX"); break; //itemx
20485 case MAPDATAITEMY: SET_MAPDATA_VAR_BYTE(itemy, "ItemY"); break; //itemy
20486 case MAPDATACOLOUR: SET_MAPDATA_VAR_INT32(color, "CSet"); break; //w
20487 case MAPDATAENEMYFLAGS: SET_MAPDATA_VAR_BYTE(enemyflags, "EnemyFlags"); break; //b
20488 case MAPDATADOOR: SET_MAPDATA_BYTE_INDEX(door, "Door", 3); break; //b, 4 of these
20489 case MAPDATATILEWARPDMAP: SET_MAPDATA_VAR_INDEX32(tilewarpdmap, "TileWarpDMap", 3); break; //w, 4 of these
20490 case MAPDATATILEWARPSCREEN: SET_MAPDATA_BYTE_INDEX(tilewarpscr, "TileWarpScreen", 3); break; //b, 4 of these
20491 case MAPDATAEXITDIR: SET_MAPDATA_VAR_BYTE(exitdir, "ExitDir"); break; //b
20492 case MAPDATAENEMY:
20493 {
20494 int32_t indx = (ri->d[rINDEX] / 10000);
20495 int32_t enemyid = value/10000;
20496 if( ((unsigned)indx) > 9 )
20497 {
20498 Z_scripterrlog("Invalid Index passed to mapdata->%s: %d\n", "Enemy[]", (indx));
20499 }
20500 else if ( ((unsigned)enemyid) > MAXGUYS )
20501 {
20502 Z_scripterrlog("Invaid enemy ID (%d) passed to Mapdata->%s.", enemyid,"Enemy[]");
20503 }
20504 else if (mapscr *m = GetMapscr(ri->mapsref))
20505 {
20506 m->enemy[indx] = enemyid;
20507 }
20508 else
20509 {
20510 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","Enemy[]");
20511 }
20512 break;
20513 }
20514 //case MAPDATAENEMY: SET_MAPDATA_VAR_INDEX32(enemy, "Enemy", 9); break; //w, 10 of these
20515 case MAPDATAPATTERN: SET_MAPDATA_VAR_BYTE(pattern, "Pattern"); break; //b
20516 case MAPDATASIDEWARPTYPE: SET_MAPDATA_BYTE_INDEX(sidewarptype, "SideWarpType", 3); break; //b, 4 of these
20517 //case MAPDATASIDEWARPOVFLAGS: SET_MAPDATA_VAR_BYTE(sidewarpoverlayflags, "SideWarpOverlayFlags"); break; //b
20518 case MAPDATAWARPARRIVALX: SET_MAPDATA_VAR_BYTE(warparrivalx, "WarpArrivalX"); break; //b
20519 case MAPDATAWARPARRIVALY: SET_MAPDATA_VAR_BYTE(warparrivaly, "WarpArrivalY"); break; //b
20520 case MAPDATAPATH: SET_MAPDATA_BYTE_INDEX(path, "MazePath", 3); break; //b, 4 of these
20521 case MAPDATASIDEWARPSC: SET_MAPDATA_BYTE_INDEX(sidewarpscr, "SideWarpScreen", 3); break; //b, 4 of these
20522 case MAPDATAINITDARRAY:
20523 {
20524
20525 if (mapscr *m = GetMapscr(ri->mapsref))
20526 {
20527 m->screeninitd[ri->d[rINDEX]/10000] = value;
20528 }
20529 else
20530 {
20531 Z_scripterrlog("Script attempted to use a mapdata->InitD[%d] on a pointer that is uninitialised\n",ri->d[rINDEX]/10000);
20532 }
20533 break;
20534 }
20535
20536
20537 case MAPDATALAYERINVIS:
20538 {
20539 int32_t indx = ri->d[rINDEX] / 10000;
20540 if(indx < 0 || indx > 6 )
20541 {
20542 Z_scripterrlog("Invalid Index passed to mapdata->LayerInvisible[]: %d\n", indx);
20543 }
20544 else
20545 {
20546
20547 if (mapscr *m = GetMapscr(ri->mapsref))
20548 {
20549 if(value)
20550 {
20551 tmpscr->hidelayers |= (1<<indx);
20552 }
20553 else
20554 {
20555 tmpscr->hidelayers &= ~(1<<indx);
20556 }
20557 }
20558 else
20559 {
20560 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","LayerInvisible");
20561 }
20562 }
20563 break;
20564 }
20565 case MAPDATASCRIPTDRAWS:
20566 {
20567 int32_t indx = ri->d[rINDEX] / 10000;
20568 if(indx < 0 || indx > 7 )
20569 {
20570 Z_scripterrlog("Invalid Index passed to mapdata->DisableScriptDraw[]: %d\n", indx);
20571 }
20572 else
20573 {
20574 if (mapscr *m = GetMapscr(ri->mapsref))
20575 {
20576 if(value)
20577 {
20578 tmpscr->hidescriptlayers &= ~(1<<indx);
20579 }
20580 else
20581 {
20582 tmpscr->hidescriptlayers |= (1<<indx);
20583 }
20584 }
20585 else
20586 {
20587 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","DisableScriptDraw");
20588 }
20589 }
20590 break;
20591 }
20592
20593 case MAPDATATILEWARPOVFLAGS:
20594 {
20595 int32_t indx = ri->d[rINDEX] / 10000;
20596 if ( ((unsigned)indx) > 3 )
20597 {
20598 Z_scripterrlog("Invalid index passed to TileWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
20599 }
20600 else if (mapscr *m = GetMapscr(ri->mapsref))
20601 {
20602 if ( value ) m->tilewarpoverlayflags |= (1<<indx);
20603 else m->tilewarpoverlayflags &= ~(1<<indx);
20604 }
20605 else
20606 {
20607 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","NumFFCs[]");
20608 }
20609 break;
20610 }
20611
20612 case MAPDATASIDEWARPOVFLAGS:
20613 {
20614 int32_t indx = ri->d[rINDEX] / 10000;
20615 if ( ((unsigned)indx) > 3 )
20616 {
20617 Z_scripterrlog("Invalid index passed to SideWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
20618 }
20619 else if (mapscr *m = GetMapscr(ri->mapsref))
20620 {
20621 if ( value ) m->sidewarpoverlayflags |= (1<<indx);
20622 else m->sidewarpoverlayflags &= ~(1<<indx);
20623 }
20624 else
20625 {
20626 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","NumFFCs[]");
20627 }
20628 break;
20629 }
20630
20631 case MAPDATASIDEWARPDMAP: SET_MAPDATA_VAR_INDEX32(sidewarpdmap, "SideWarpDMap", 3); break; //w, 4 of these
20632 case MAPDATASIDEWARPINDEX: SET_MAPDATA_VAR_BYTE(sidewarpindex, "SideWarpIndex"); break; //b
20633 case MAPDATAUNDERCOMBO: SET_MAPDATA_VAR_INT32(undercombo, "UnderCombo"); break; //w
20634 case MAPDATAUNDERCSET: SET_MAPDATA_VAR_BYTE(undercset, "UnderCSet"); break; //b
20635 case MAPDATACATCHALL: SET_MAPDATA_VAR_INT32(catchall, "Catchall"); break; //W
20636
20637 case MAPDATACSENSITIVE: SET_MAPDATA_VAR_BYTE(csensitive, "CSensitive"); break; //B
20638 case MAPDATANORESET: SET_MAPDATA_VAR_INT32(noreset, "NoReset"); break; //W
20639 case MAPDATANOCARRY: SET_MAPDATA_VAR_INT32(nocarry, "NoCarry"); break; //W
20640 //! Layer arrays should be a size of 7, and return the current screen / map / and OP_OPAQUE
20641 //! if you try to read 0, so that they correspond to actual layer IDs.
20642 //!
20643 case MAPDATALAYERMAP: SET_MAPDATA_LAYER_INDEX(layermap, "LayerMap", 6); break; //B, 6 OF THESE
20644 case MAPDATALAYERSCREEN: SET_MAPDATA_LAYERSCREEN_INDEX(layerscreen, "LayerScreen", 6); break; //B, 6 OF THESE
20645 case MAPDATALAYEROPACITY: SET_MAPDATA_LAYER_INDEX(layeropacity, "LayerOpacity", 6); break; //B, 6 OF THESE
20646 case MAPDATATIMEDWARPTICS: SET_MAPDATA_VAR_INT32(timedwarptics, "TimedWarpTimer"); break; //W
20647 case MAPDATANEXTMAP: SET_MAPDATA_VAR_BYTE(nextmap, "NextMap"); break; //B
20648 case MAPDATANEXTSCREEN: SET_MAPDATA_VAR_BYTE(nextscr, "NextScreen"); break; //B
20649 case MAPDATASECRETCOMBO: SET_MAPDATA_VAR_INDEX32(secretcombo, "SecretCombo", 127); break; //W, 128 OF THESE
20650 case MAPDATASECRETCSET: SET_MAPDATA_BYTE_INDEX(secretcset, "SecretCSet", 127); break; //B, 128 OF THESE
20651 case MAPDATASECRETFLAG: SET_MAPDATA_BYTE_INDEX(secretflag, "SecretFlags", 127); break; //B, 128 OF THESE
20652 case MAPDATAVIEWX: break;//SET_MAPDATA_VAR_INT32(viewX, "ViewX"); break; //W
20653 case MAPDATASCRIPT:
20654 {
20655 if (mapscr *m = GetMapscr(ri->mapsref))
20656 {
20657 if(ri->mapsref == MAPSCR_TEMP0) //This mapsref references tmpscr, so can reference a running script!
20658 {
20659 FFScript::deallocateAllArrays(ScriptType::Screen, 0);
20660
20661 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
20662 {
20663 for(int32_t q=0; q<8; q++)
20664 tmpscr->screeninitd[q] = 0;
20665 }
20666
20667 FFCore.ref(ScriptType::Screen, 0).Clear();
20668 }
20669 m->script=vbound(value/10000, 0, NUMSCRIPTSCREEN-1);
20670 }
20671 else
20672 {
20673 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Script");
20674 }
20675 break;
20676
20677 }
20678 case MAPDATAVIEWY: break;//SET_MAPDATA_VAR_INT32(viewY, "ViewY"); break; //W
20679 case MAPDATASCREENWIDTH: break;//SET_MAPDATA_VAR_BYTE(scrWidth, "Width"); break; //B
20680 case MAPDATASCREENHEIGHT: break;//SET_MAPDATA_VAR_BYTE(scrHeight, "Height"); break; //B
20681 case MAPDATAENTRYX: SET_MAPDATA_VAR_BYTE(entry_x, "EntryX"); break; //B
20682 case MAPDATAENTRYY: SET_MAPDATA_VAR_BYTE(entry_y, "EntryY"); break; //B
20683 case MAPDATAFFDATA:
20684 {
20685 int32_t indx = (ri->d[rINDEX] / 10000)-1;
20686 if(indx < 0 || indx > MAXFFCS-1 )
20687 {
20688 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), "FFCData");
20689 }
20690 else if (mapscr *m = GetMapscr(ri->mapsref))
20691 {
20692 m->ffcs[indx].setData(value/10000);
20693 }
20694 else
20695 {
20696 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised", "FFCData");
20697 }
20698 break; //W, MAXFFCS OF THESE
20699 }
20700 case MAPDATAFFCSET: SET_MAPDATA_FFC_INDEX32(cset, "FFCCSet", MAXFFCS-1); break; //B, MAXFFCS
20701 case MAPDATAFFDELAY: SET_MAPDATA_FFC_INDEX32(delay, "FFCDelay", MAXFFCS-1); break; //W, MAXFFCS
20702 case MAPDATAFFX: SET_MAPDATA_FFCPOS_INDEX32(x, "FFCX", MAXFFCS-1); break; //INT32, MAXFFCS OF THESE
20703 case MAPDATAFFY: SET_MAPDATA_FFCPOS_INDEX32(y, "FFCY", MAXFFCS-1); break; //..
20704 case MAPDATAFFXDELTA: SET_MAPDATA_FFCPOS_INDEX32(vx, "FFCVx", MAXFFCS-1); break; //..
20705 case MAPDATAFFYDELTA: SET_MAPDATA_FFCPOS_INDEX32(vy, "FFCVy", MAXFFCS-1); break; //..
20706 case MAPDATAFFXDELTA2: SET_MAPDATA_FFCPOS_INDEX32(ax, "FFCAx", MAXFFCS-1); break; //..
20707 case MAPDATAFFYDELTA2: SET_MAPDATA_FFCPOS_INDEX32(ay, "FFCAy", MAXFFCS-1); break; //..
20708
20709 case MAPDATAFFFLAGS:
20710 {
20711 int32_t indx = (ri->d[rINDEX] / 10000)-1;
20712 if(indx < 0 || indx > MAXFFCS-1)
20713 {
20714 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), "FFCFlags");
20715 }
20716 else if (mapscr *m = GetMapscr(ri->mapsref))
20717 {
20718 m->ffcs[indx].flags = value/10000;
20719 m->ffcs[indx].updateSolid();
20720 }
20721 else
20722 {
20723 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCFlags");
20724 }
20725 break;
20726 }
20727
20728 //Number of ffcs that are in use (have valid data
20729 case MAPDATANUMFF:
20730 {
20731 break;
20732 }
20733
20734 case MAPDATASIDEWARPID:
20735 {
20736
20737 int32_t indx = ri->d[rINDEX] / 10000; //dir
20738 if (mapscr *m = GetMapscr(ri->mapsref))
20739 {
20740 int32_t new_warp_return = vbound((value / 10000),-1,3); //none, A, B, C, D
20741 if(new_warp_return == -1)
20742 {
20743 m->flags2 &= ~(1<<indx); //Unset the "Enabled" flag for this dir
20744 m->sidewarpindex &= ~(3<<(2*indx)); //Clear the dir as well.
20745 }
20746 else
20747 {
20748 m->flags2 |= 1<<indx; //Set the "Enabled" flag for this dir
20749 m->sidewarpindex &= ~(3<<(2*indx)); //Clear the dir bits
20750 m->sidewarpindex |= (new_warp_return<<(2*indx)); //Set the new dir
20751 }
20752 }
20753 else
20754 {
20755 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","SideWarpID");
20756 }
20757 break;
20758 }
20759
20760 case MAPDATATWARPRETSQR:
20761 {
20762 int32_t indx = ri->d[rINDEX] / 10000;
20763 if ( ((unsigned)indx) > 3)
20764 {
20765 Z_scripterrlog("Invalid Array Index passed to mapdata->TileWarpReturnSquare[]: %d\n", indx);
20766 }
20767 else if (mapscr *m = GetMapscr(ri->mapsref))
20768 {
20769 int32_t wrindex = vbound(value/10000, 0, 3);
20770 m->warpreturnc = (m->warpreturnc&~(3<<(indx*2))) | (wrindex<<(indx*2));
20771 }
20772 else
20773 {
20774 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str");
20775 }
20776 break;
20777 }
20778
20779 //
20780 case MAPDATASWARPRETSQR:
20781 {
20782
20783 int32_t indx = ri->d[rINDEX] / 10000;
20784 if ( ((unsigned)indx) > 3)
20785 {
20786 Z_scripterrlog("Invalid Array Index passed to MAPDATA->SideWarpReturnSquare[]: %d\n", indx);
20787 }
20788 else if (mapscr *m = GetMapscr(ri->mapsref))
20789 {
20790 int32_t wrindex = vbound(value/10000, 0, 3);
20791 m->warpreturnc = (m->warpreturnc&~(3<<(8+(indx*2)))) | (wrindex<<(8+(indx*2)));
20792 }
20793 else
20794 {
20795 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str");
20796 }
20797 break;
20798 }
20799
20800 case MAPDATAFFWIDTH:
20801 {
20802 int32_t indx = (ri->d[rINDEX] / 10000)-1;
20803 if ( indx < 0 || indx > MAXFFCS-1 )
20804 {
20805 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCTileWidth[]: %d\n", indx+1);
20806 }
20807 else if ( (value/10000) < 0 || (value/10000) > 4 )
20808 {
20809 Z_scripterrlog("Invalid WIDTH value passed to MapData->FFCTileWidth[]: %d\n", value/10000);
20810 }
20811 else if (mapscr *m = GetMapscr(ri->mapsref))
20812 {
20813 m->ffTileWidth(indx, (value/10000));
20814 }
20815 else
20816 {
20817 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCTileWidth[]");
20818 }
20819 break;
20820 }
20821
20822 case MAPDATAFFHEIGHT:
20823 {
20824 int32_t indx = (ri->d[rINDEX] / 10000)-1;
20825 if ( indx < 0 || indx > MAXFFCS-1 )
20826 {
20827 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCTileHeight[]: %d\n", indx+1);
20828 }
20829 else if ( (value/10000) < 0 || (value/10000) > 4 )
20830 {
20831 Z_scripterrlog("Invalid WIDTH value passed to MapData->FFCTileHeight[]: %d\n", value/10000);
20832 }
20833 else if (mapscr *m = GetMapscr(ri->mapsref))
20834 {
20835 m->ffTileHeight(indx, (value/10000));
20836 }
20837 else
20838 {
20839 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCTileHeight[]");
20840 }
20841 break;
20842
20843 }
20844
20845 case MAPDATAFFEFFECTWIDTH:
20846 {
20847 int32_t indx = (ri->d[rINDEX] / 10000)-1;
20848 if ( indx < 0 || indx > MAXFFCS-1 )
20849 {
20850 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCEffectWidth[]: %d\n", indx+1);
20851 }
20852 else if ( (value/10000) < 0 )
20853 {
20854 Z_scripterrlog("Invalid WIDTH value passed to MapData->FFCEffectWidth[]: %d\n", value/10000);
20855 }
20856 else if (mapscr *m = GetMapscr(ri->mapsref))
20857 {
20858 m->ffEffectWidth(indx, (value/10000));
20859 }
20860 else
20861 {
20862 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCEffectWidth[]");
20863 }
20864 break;
20865 }
20866
20867 case MAPDATAFFEFFECTHEIGHT:
20868 {
20869 int32_t indx = (ri->d[rINDEX] / 10000)-1;
20870 if ( indx < 0 || indx > MAXFFCS-1 )
20871 {
20872 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCEffectHeight[]: %d\n", indx+1);
20873 }
20874 else if ( (value/10000) < 0 )
20875 {
20876 Z_scripterrlog("Invalid HEIGHT value passed to MapData->FFCEffectHeight[]: %d\n", value/10000);
20877 }
20878 else if (mapscr *m = GetMapscr(ri->mapsref))
20879 {
20880 m->ffEffectHeight(indx, (value/10000));
20881 }
20882 else
20883 {
20884 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCEffectHeight[]");
20885 }
20886 break;
20887 }
20888
20889 case MAPDATAFFLINK: SET_MAPDATA_FFC_INDEX_VBOUND(link, "FFCLink", MAXFFCS-1, 0, MAXFFCS); break; //B, MAXFFCS OF THESE
20890 case MAPDATAFFSCRIPT: SET_MAPDATA_FFC_INDEX_VBOUND(script, "FFCScript", MAXFFCS-1, 0, 255); break; //W, 32 OF THESE
20891
20892 case MAPDATAINTID: //Same form as SetScreenD()
20893 //SetFFCInitD(ffindex, d, value)
20894 {
20895 if (mapscr *m = GetMapscr(ri->mapsref))
20896 {
20897 //int32_t ffindex = ri->d[rINDEX]/10000;
20898 //int32_t d = ri->d[rINDEX2]/10000;
20899 //int32_t v = (value/10000);
20900 int32_t ffid = (ri->d[rINDEX]/10000) -1;
20901 int32_t indx = ri->d[rINDEX2]/10000;
20902
20903 if ( (unsigned)ffid > MAXFFCS-1 )
20904 {
20905 Z_scripterrlog("Invalid FFC id passed to mapdata->FFCInitD[]: %d",ffid);
20906 }
20907 else if ( (unsigned)indx > 7 )
20908 {
20909 Z_scripterrlog("Invalid InitD[] index passed to mapdata->FFCInitD[]: %d",indx);
20910 }
20911 else
20912 {
20913 m->ffcs[ffid].initd[indx] = value;
20914 }
20915 }
20916 else
20917 {
20918 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","SetFFCInitD()");
20919 }
20920 break;
20921 }
20922
20923
20924 //initd //INT32 , 32 OF THESE, EACH WITH 10 INDICES.
20925
20926
20927 case MAPDATAINITA:
20928 //same form as SetScreenD
20929 {
20930 if (mapscr *m = GetMapscr(ri->mapsref))
20931 {//int32_t ffindex = ri->d[rINDEX]/10000;
20932 //int32_t d = ri->d[rINDEX2]/10000;
20933 //int32_t v = (value/10000);
20934 int32_t ffid = (ri->d[rINDEX]/10000) -1;
20935 int32_t indx = ri->d[rINDEX2]/10000;
20936
20937 if ( (unsigned)ffid > MAXFFCS-1 )
20938 {
20939 Z_scripterrlog("Invalid FFC id passed to mapdata->FFCInitD[]: %d",ffid);
20940 }
20941 else if ( (unsigned)indx > 7 )
20942 {
20943 Z_scripterrlog("Invalid InitD[] index passed to mapdata->FFCInitD[]: %d",indx);
20944 }
20945 else
20946 {
20947 m->ffcs[ffid].inita[indx] = value;
20948 }
20949 }
20950 else
20951 {
20952 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","SetFFCInitA()");
20953 }
20954 break;
20955 }
20956
20957 case MAPDATAFFINITIALISED:
20958 {
20959 int32_t indx = ri->d[rINDEX] / 10000;
20960 if(indx < 0 || indx > MAXFFCS-1)
20961 {
20962 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", "FFCRunning", indx);
20963 }
20964 else if (mapscr *m = GetMapscr(ri->mapsref))
20965 {
20966 get_script_engine_data(ScriptType::FFC, indx).initialized = (value/10000) ? true : false;
20967 }
20968 else
20969 {
20970 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n", "FFCRunning");
20971 }
20972 }
20973 break;
20974
20975 case MAPDATASCRIPTENTRY: SET_MAPDATA_VAR_INT32(script_entry, "ScriptEntry"); break; //W
20976 case MAPDATASCRIPTOCCUPANCY: SET_MAPDATA_VAR_INT32(script_occupancy, "ScriptOccupancy"); break;//W
20977 case MAPDATASCRIPTEXIT: SET_MAPDATA_VAR_INT32(script_exit, "ExitScript"); break; //W
20978 case MAPDATAOCEANSFX:
20979 {
20980 if (mapscr *m = GetMapscr(ri->mapsref))
20981 {
20982 int32_t v = vbound(value/10000, 0, 255);
20983 if(m == tmpscr && m->oceansfx != v)
20984 {
20985 stop_sfx(m->oceansfx);
20986 m->oceansfx = v;
20987 cont_sfx(m->oceansfx);
20988 }
20989 else m->oceansfx = v;
20990 }
20991 else
20992 {
20993 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","OceanSFX");
20994 }
20995 break;
20996 }
20997 case MAPDATABOSSSFX: SET_MAPDATA_VAR_BYTE(bosssfx, "BossSFX"); break; //B
20998 case MAPDATASECRETSFX: SET_MAPDATA_VAR_BYTE(secretsfx, "SecretSFX"); break; //B
20999 case MAPDATAHOLDUPSFX: SET_MAPDATA_VAR_BYTE(holdupsfx, "ItemSFX"); break; //B
21000 case MAPDATASCREENMIDI:
21001 {
21002 if (mapscr *m = GetMapscr(ri->mapsref))
21003 {
21004 m->screen_midi = vbound((value / 10000)-(MIDIOFFSET_MAPSCR-MIDIOFFSET_ZSCRIPT),-1,32767);
21005 }
21006 else
21007 {
21008 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","MIDI");
21009 }
21010 break;
21011 }
21012 case MAPDATALENSLAYER: SET_MAPDATA_VAR_BYTE(lens_layer, "LensLayer"); break; //B, OLD QUESTS ONLY?
21013
21014
21015 case MAPDATAFLAGS:
21016 {
21017 int32_t flagid = (ri->d[rINDEX])/10000;
21018 //bool valtrue = ( value ? 10000 : 0);
21019 if(mapscr *m = GetMapscr(ri->mapsref))
21020 {
21021 switch(flagid)
21022 {
21023 case 0: m->flags = (value / 10000); break;
21024 case 1: m->flags2 = (value / 10000); break;
21025 case 2: m->flags3 = (value / 10000); break;
21026 case 3: m->flags4 = (value / 10000); break;
21027 case 4: m->flags5 = (value / 10000); break;
21028 case 5: m->flags6 = (value / 10000); break;
21029 case 6: m->flags7 = (value / 10000); break;
21030 case 7: m->flags8 = (value / 10000); break;
21031 case 8: m->flags9 = (value / 10000); break;
21032 case 9: m->flags10 = (value / 10000); break;
21033 default:
21034 {
21035 Z_scripterrlog("Invalid index passed to mapdata->flags[]: %d\n", flagid);
21036 break;
21037 }
21038 }
21039 }
21040 else
21041 {
21042 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Flags[]");
21043 }
21044 break;
21045 //SET_MAPDATA_BYTE_INDEX //B, 11 OF THESE, flags, flags2-flags10
21046 }
21047
21048 case MAPDATAMISCD:
21049 {
21050 if(mapscr* m = GetMapscr(ri->mapsref))
21051 {
21052 int32_t indx = (ri->d[rINDEX])/10000;
21053 int32_t mi = get_mi(ri->mapsref);
21054 if(mi<0) break;
21055 if( ((unsigned)indx) > 7 )
21056 {
21057 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", indx);
21058 break;
21059 }
21060 else
21061 {
21062 game->screen_d[mi][indx] = value/10000;
21063 break;
21064 }
21065 }
21066 else
21067 {
21068 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","D[]");
21069 }
21070 break;
21071 }
21072
21073
21074 case MAPDATACOMBODD:
21075 {
21076 80782 int32_t pos = (ri->d[rINDEX])/10000;
21077 80782 int32_t val = (value/10000);
21078
21079
1/2
✓ Branch 0 taken 80782 times.
✗ Branch 1 not taken.
80782 if(mapscr *m = GetMapscr(ri->mapsref))
21080 {
21081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80782 times.
80782 if ( ((unsigned) pos) > 175 )
21082 {
21083 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboD[]\n", pos);
21084 }
21085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80782 times.
80782 else if ( ((unsigned) val) >= MAXCOMBOS )
21086 {
21087 Z_scripterrlog("Invalid combo ID %d used to write to mapdata->ComboD[]\n", val);
21088 }
21089 else
21090 {
21091 80782 screen_combo_modify_preroutine(m,pos);
21092 80782 m->data[pos]=val;
21093 80782 screen_combo_modify_postroutine(m,pos);
21094 }
21095 80782 }
21096 else
21097 {
21098 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboD[]");
21099 }
21100 }
21101 80782 break;
21102
21103 case MAPDATACOMBOCD:
21104 {
21105 2497 int32_t pos = (ri->d[rINDEX])/10000;
21106 2497 int32_t val = (value/10000); //cset
21107
1/2
✓ Branch 0 taken 2497 times.
✗ Branch 1 not taken.
2497 if(mapscr *m = GetMapscr(ri->mapsref))
21108 {
21109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2497 times.
2497 if ( ((unsigned) pos) > 175 )
21110 {
21111 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboC[]\n", pos);
21112 }
21113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2497 times.
2497 else if ( ((unsigned) val) >= 15 )
21114 {
21115 Z_scripterrlog("Invalid CSet ID %d used to write to mapdata->ComboC[]\n", val);
21116 }
21117 else
21118 {
21119 2497 screen_combo_modify_preroutine(m,pos);
21120 2497 m->cset[pos]=(val)&15;
21121 2497 screen_combo_modify_postroutine(m,pos);
21122 }
21123 2497 }
21124 else
21125 {
21126 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboC[]");
21127 }
21128 }
21129 2497 break;
21130
21131 case MAPDATACOMBOFD:
21132 {
21133 56174 int32_t pos = (ri->d[rINDEX])/10000;
21134 56174 int32_t val = (value/10000); //flag
21135
1/2
✓ Branch 0 taken 56174 times.
✗ Branch 1 not taken.
56174 if(mapscr *m = GetMapscr(ri->mapsref))
21136 {
21137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56174 times.
56174 if ( ((unsigned) pos) > 175 )
21138 {
21139 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboF[]\n", pos);
21140 }
21141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56174 times.
56174 else if ( ((unsigned) val) >= 256 )
21142 {
21143 Z_scripterrlog("Invalid Flag ID %d used to write to mapdata->ComboF[]\n", val);
21144 }
21145
21146 else
21147 56174 m->sflag[pos]=(val);
21148 56174 }
21149 else
21150 {
21151 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboF[]");
21152 }
21153 }
21154 56174 break;
21155
21156 case MAPDATACOMBOTD:
21157 {
21158 int32_t pos = (ri->d[rINDEX])/10000;
21159 int32_t val = (value/10000); //type
21160 if(mapscr *m = GetMapscr(ri->mapsref))
21161 {
21162 if ( ((unsigned) pos) > 175 )
21163 {
21164 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboT[]\n", pos);
21165 }
21166 else if ( ((unsigned) val) >= cMAX )
21167 {
21168 Z_scripterrlog("Invalid Type ID %d used to write to mapdata->ComboT[]\n", val);
21169 }
21170 else
21171 {
21172 auto cid = m->data[pos];
21173 screen_combo_modify_pre(cid);
21174 combobuf[cid].type=val;
21175 screen_combo_modify_post(cid);
21176 }
21177 }
21178 else
21179 {
21180 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboT[]");
21181 }
21182 }
21183 break;
21184
21185 case MAPDATACOMBOID:
21186 {
21187 int32_t pos = (ri->d[rINDEX])/10000;
21188 int32_t val = (value/10000); //iflag
21189 if(mapscr *m = GetMapscr(ri->mapsref))
21190 {
21191 if ( ((unsigned) pos) > 175 )
21192 {
21193 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboI[]\n", pos);
21194 }
21195 else if ( ((unsigned) val) >= 256 )
21196 {
21197 Z_scripterrlog("Invalid Flag ID %d used to write to mapdata->ComboI[]\n", val);
21198 }
21199
21200 else
21201 combobuf[m->data[pos]].flag=value/10000;
21202 }
21203 else
21204 {
21205 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboI[]");
21206 }
21207 }
21208 break;
21209
21210 case MAPDATACOMBOSD:
21211 {
21212 int32_t pos = (ri->d[rINDEX])/10000;
21213 int32_t val = (value/10000); //solidity
21214 if(mapscr *m = GetMapscr(ri->mapsref))
21215 {
21216 if ( ((unsigned) pos) > 175 )
21217 {
21218 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboS[]\n", pos);
21219 }
21220 else if ( ((unsigned) val) >= 16 )
21221 {
21222 Z_scripterrlog("Invalid Solidity %d used to write to mapdata->ComboS[]\n", val);
21223 }
21224
21225 else
21226 {
21227 combobuf[m->data[pos]].walk &= ~0x0F;
21228 combobuf[m->data[pos]].walk |= (val)&0x0F;
21229 }
21230 }
21231 else
21232 {
21233 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboS[]");
21234 }
21235 }
21236 break;
21237
21238 case MAPDATACOMBOED:
21239 {
21240 int32_t pos = (ri->d[rINDEX])/10000;
21241 int32_t val = (value/10000); //solidity
21242 if(mapscr *m = GetMapscr(ri->mapsref))
21243 {
21244 if ( ((unsigned) pos) > 175 )
21245 {
21246 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboE[]\n", pos);
21247 }
21248 else if ( ((unsigned) val) >= 16 )
21249 {
21250 Z_scripterrlog("Invalid Solidity %d used to write to mapdata->ComboE[]\n", val);
21251 }
21252
21253 else
21254 {
21255 combobuf[m->data[pos]].walk &= ~0xF0;
21256 combobuf[m->data[pos]].walk |= ((val)&0x0F)<<4;
21257 }
21258 }
21259 else
21260 {
21261 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboE[]");
21262 }
21263 }
21264 break;
21265
21266 case MAPDATASCREENSTATED:
21267 {
21268 if(mapscr* m = GetMapscr(ri->mapsref))
21269 {
21270 int32_t mi = get_mi(ri->mapsref);
21271 if(mi<0) break;
21272 (value)?setmapflag(mi, 1<<((ri->d[rINDEX])/10000)) : unsetmapflag(mi, 1 << ((ri->d[rINDEX]) / 10000));
21273 }
21274 else
21275 {
21276 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","State[]");
21277 }
21278 }
21279 break;
21280 case MAPDATAEXSTATED:
21281 {
21282 if(mapscr* m = GetMapscr(ri->mapsref))
21283 {
21284 int32_t mi = get_mi(ri->mapsref);
21285 if(mi<0) break;
21286 (value)?setxmapflag(mi, 1<<((ri->d[rINDEX])/10000)) : unsetxmapflag(mi, 1 << ((ri->d[rINDEX]) / 10000));
21287 }
21288 else
21289 {
21290 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","State[]");
21291 }
21292 break;
21293 }
21294 case MAPDATALENSSHOWS:
21295 {
21296 int ind = ri->d[rINDEX]/10000;
21297 if(ind < 0 || ind > 6)
21298 Z_scripterrlog("Bad index mapdata->LensShows[%d]\n",ind);
21299 else if(mapscr *m = GetMapscr(ri->mapsref))
21300 {
21301 SETFLAG(m->lens_show, 1<<ind, value);
21302 if(value) m->lens_hide &= ~(1<<ind);
21303 }
21304 else Z_scripterrlog("mapdata->LensShows[] pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
21305 break;
21306 }
21307 case MAPDATALENSHIDES:
21308 {
21309 int ind = ri->d[rINDEX]/10000;
21310 if(ind < 0 || ind > 6)
21311 Z_scripterrlog("Bad index mapdata->LensHides[%d]\n",ind);
21312 else if(mapscr *m = GetMapscr(ri->mapsref))
21313 {
21314 SETFLAG(m->lens_hide, 1<<ind, value);
21315 if(value) m->lens_show &= ~(1<<ind);
21316 }
21317 else Z_scripterrlog("mapdata->LensHides[] pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
21318 break;
21319 }
21320
21321 ///----------------------------------------------------------------------------------------------------//
21322 //shopdata sd-> Variables
21323
21324 case SHOPDATAITEM:
21325 {
21326
21327 int32_t ref = ri->shopsref;
21328 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
21329 int32_t indx = ri->d[rINDEX] / 10000;
21330 if ( indx < 0 || indx > 2 )
21331 {
21332 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "Item");
21333 break;
21334 }
21335 else
21336 {
21337 if ( isInfo )
21338 {
21339 Z_scripterrlog("Attempted to write an 'item' to an infoshop, using shop ID: %d\n", ri->shopsref);
21340 break;
21341 }
21342 else
21343 {
21344 QMisc.shop[ref].item[indx] = (byte)(vbound((value/10000), 0, 255));
21345 break;
21346 }
21347 }
21348 }
21349 break;
21350 //SET_SHOPDATA_VAR_INDEX(item, "Item", 2); break;
21351 case SHOPDATAHASITEM:
21352 {
21353
21354 int32_t ref = ri->shopsref;
21355 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
21356 int32_t indx = ri->d[rINDEX] / 10000;
21357 if ( indx < 0 || indx > 2 )
21358 {
21359 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "HasItem");
21360 break;
21361 }
21362 else
21363 {
21364 if ( isInfo )
21365 {
21366 Z_scripterrlog("Attempted to write 'hasitem' to an infoshop, using shop ID: %d\n", ri->shopsref);
21367 break;
21368 }
21369 else
21370 {
21371 QMisc.shop[ref].hasitem[indx] = (byte)(vbound((value/10000), 0, 255)); break;
21372 }
21373 }
21374 }
21375 break;
21376 //SET_SHOPDATA_VAR_INDEX(hasitem, "HasItem", 2); break;
21377 case SHOPDATAPRICE:
21378 {
21379
21380 int32_t ref = ri->shopsref;
21381 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
21382 int32_t indx = ri->d[rINDEX] / 10000;
21383 if ( indx < 0 || indx > 2 )
21384 {
21385 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "Price");
21386 break;
21387 }
21388 else
21389 {
21390 if ( isInfo )
21391 {
21392 QMisc.info[ref].price[indx] = (word)(vbound((value/10000), 0, 65535));
21393 break;
21394 }
21395 else
21396 {
21397 QMisc.shop[ref].price[indx] = (word)(vbound((value/10000), 0, 65535));
21398 break;
21399 }
21400 }
21401 }
21402 //SET_SHOPDATA_VAR_INDEX(price, "Price", 2); break;
21403 //Pay for info
21404 case SHOPDATASTRING:
21405 {
21406 {
21407 if ( ri->shopsref < NUMSHOPS || ri->shopsref > NUMINFOSHOPS )
21408 {
21409 Z_scripterrlog("Invalid Info Shop ID passed to shopdata->String[]: %d\n", ri->shopsref);
21410 break;
21411 }
21412 else
21413 {
21414 int32_t ref = ri->shopsref;
21415 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
21416 int32_t indx = ri->d[rINDEX] / 10000;
21417 if ( indx < 0 || indx > 2 )
21418 {
21419 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "HasItem");
21420 break;
21421 }
21422 else
21423 {
21424 if ( isInfo )
21425 {
21426 QMisc.info[ref].str[indx] = (word)(vbound((value/10000), 0, 32767));
21427 break;
21428 }
21429 else
21430 {
21431 QMisc.shop[ref].str[indx] = (word)(vbound((value/10000), 0, 32767));
21432 break;
21433 }
21434 }
21435
21436
21437 }
21438
21439 //GET_SHOPDATA_VAR_INDEX(str, String, 2); break;
21440 } break;
21441 }
21442
21443 ///----------------------------------------------------------------------------------------------------//
21444 //dmapdata dmd-> Variables
21445 case DMAPDATAMAP: //byte
21446 {
21447 DMaps[ri->dmapsref].map = ((byte)(value / 10000)) - 1; break;
21448 }
21449 case DMAPDATALEVEL: //word
21450 {
21451 DMaps[ri->dmapsref].level = ((word)(value / 10000)); break;
21452 }
21453 case DMAPDATAOFFSET: //char
21454 {
21455 DMaps[ri->dmapsref].xoff = ((char)(value / 10000)); break;
21456 }
21457 case DMAPDATACOMPASS: //byte
21458 {
21459 DMaps[ri->dmapsref].compass = ((byte)(value / 10000)); break;
21460 }
21461 case DMAPDATAPALETTE: //word
21462 {
21463 DMaps[ri->dmapsref].color= ((word)(value / 10000));
21464 if(ri->dmapsref == currdmap)
21465 {
21466 loadlvlpal(DMaps[ri->dmapsref].color);
21467 currcset = DMaps[ri->dmapsref].color;
21468 }
21469 break;
21470 }
21471 case DMAPDATAMIDI: //byte
21472 {
21473 DMaps[ri->dmapsref].midi = ((byte)((value / 10000)+MIDIOFFSET_DMAP)); break;
21474 }
21475 case DMAPDATACONTINUE: //byte
21476 {
21477 DMaps[ri->dmapsref].cont = ((byte)(value / 10000)); break;
21478 }
21479 case DMAPDATATYPE: //byte
21480 {
21481 DMaps[ri->dmapsref].type = (((byte)(value / 10000))&dmfTYPE) | (DMaps[ri->dmapsref].type&~dmfTYPE); break;
21482 }
21483 case DMAPSCRIPT: //byte
21484 {
21485 FFScript::deallocateAllArrays(ScriptType::DMap, ri->dmapsref);
21486 DMaps[ri->dmapsref].script = vbound((value / 10000),0,NUMSCRIPTSDMAP-1); break;
21487 }
21488 case DMAPDATASIDEVIEW: //byte, treat as bool
21489 {
21490 DMaps[ri->dmapsref].sideview = ((value) ? 1 : 0); break;
21491 }
21492 case DMAPDATAGRID: //byte[8] --array
21493 {
21494 int32_t indx = ri->d[rINDEX] / 10000;
21495 if ( indx < 0 || indx > 7 )
21496 {
21497 Z_scripterrlog("Invalid index supplied to dmapdata->Grid[]: %d\n", indx); break;
21498 }
21499 else
21500 {
21501 DMaps[ri->dmapsref].grid[indx] = ((byte)(value / 10000)); break;
21502 }
21503 }
21504 case DMAPINITD:
21505 {
21506 int32_t indx = ri->d[rINDEX] / 10000;
21507 if ( indx < 0 || indx > 7 )
21508 {
21509 Z_scripterrlog("Invalid index supplied to dmapdata->InitD[]: %d\n", indx); break;
21510 }
21511 else
21512 {
21513 DMaps[ri->dmapsref].initD[indx] = value; break;
21514 }
21515 }
21516 case DMAPDATAMINIMAPTILE: //word - two of these, so let's do MinimapTile[2]
21517 {
21518 int32_t indx = ri->d[rINDEX] / 10000;
21519 switch(indx)
21520 {
21521 case 0: { DMaps[ri->dmapsref].minimap_1_tile = ((word)(value / 10000)); break; }
21522 case 1: { DMaps[ri->dmapsref].minimap_2_tile = ((word)(value / 10000)); break; }
21523 default:
21524 {
21525 Z_scripterrlog("Invalid index supplied to dmapdata->MiniMapTile[]: %d\n", indx);
21526 break;
21527 }
21528 }
21529 break;
21530 }
21531 case DMAPDATAMINIMAPCSET: //byte - two of these, so let's do MinimapCSet[2]
21532 {
21533 int32_t indx = ri->d[rINDEX] / 10000;
21534 switch(indx)
21535 {
21536 case 0: { DMaps[ri->dmapsref].minimap_1_cset= ((byte)(value / 10000)); break; }
21537 case 1: { DMaps[ri->dmapsref].minimap_2_cset= ((byte)(value / 10000)); break; }
21538 default:
21539 {
21540 Z_scripterrlog("Invalid index supplied to dmapdata->MiniMapCSet[]: %d\n", indx);
21541 break;
21542 }
21543 }
21544 break;
21545 }
21546 case DMAPDATALARGEMAPTILE: //word -- two of these, so let's to LargemapTile[2]
21547 {
21548 int32_t indx = ri->d[rINDEX] / 10000;
21549 switch(indx)
21550 {
21551 case 0: { DMaps[ri->dmapsref].largemap_1_tile = ((word)(value / 10000)); break; }
21552 case 1: { DMaps[ri->dmapsref].largemap_2_tile = ((word)(value / 10000)); break; }
21553 default:
21554 {
21555 Z_scripterrlog("Invalid index supplied to dmapdata->LargeMapTile[]: %d\n", indx);
21556 break;
21557 }
21558 }
21559 break;
21560 }
21561 case DMAPDATALARGEMAPCSET: //word -- two of these, so let's to LargemaCSet[2]
21562 {
21563 int32_t indx = ri->d[rINDEX] / 10000;
21564 switch(indx)
21565 {
21566 case 0: { DMaps[ri->dmapsref].largemap_1_cset= ((byte)(value / 10000)); break; }
21567 case 1: { DMaps[ri->dmapsref].largemap_2_cset= ((byte)(value / 10000)); break; }
21568 default:
21569 {
21570 Z_scripterrlog("Invalid index supplied to dmapdata->LargeMapCSet[]: %d\n", indx);
21571 break;
21572 }
21573 }
21574 break;
21575 }
21576 case DMAPDATAMUISCTRACK: //byte
21577 {
21578 DMaps[ri->dmapsref].tmusictrack= ((byte)(value / 10000)); break;
21579 }
21580 case DMAPDATASUBSCRA: //byte, active subscreen
21581 {
21582 bool changed = DMaps[ri->dmapsref].active_subscreen != ((byte)(value / 10000));
21583 DMaps[ri->dmapsref].active_subscreen= ((byte)(value / 10000));
21584 if(changed&&ri->dmapsref==currdmap)
21585 update_subscreens();
21586 break;
21587 }
21588 case DMAPDATASUBSCRP: //byte, passive subscreen
21589 {
21590 bool changed = DMaps[ri->dmapsref].passive_subscreen != ((byte)(value / 10000));
21591 DMaps[ri->dmapsref].passive_subscreen= ((byte)(value / 10000));
21592 if(changed&&ri->dmapsref==currdmap)
21593 update_subscreens();
21594 break;
21595 }
21596 case DMAPDATADISABLEDITEMS: //byte[MAXITEMS]
21597 {
21598 int32_t indx = ri->d[rINDEX] / 10000;
21599 if ( indx < 0 || indx > (MAXITEMS-1) )
21600 {
21601 Z_scripterrlog("Invalid index supplied to dmapdata->Grid[]: %d\n", indx); break;
21602 }
21603 else
21604 {
21605 DMaps[ri->dmapsref].disableditems[indx] = ((byte)(value / 10000)); break;
21606 }
21607 }
21608
21609 case DMAPDATAFLAGARR: //int32_t
21610 {
21611 int32_t indx = ri->d[rINDEX] / 10000;
21612 if ( ((unsigned)indx) > 31 )
21613 {
21614 Z_scripterrlog("Invalid index supplied to dmapdata->Flags[]: %d\n", indx);
21615 break;
21616 }
21617 if ( value ) DMaps[ri->dmapsref].flags |= (1<<indx);
21618 else DMaps[ri->dmapsref].flags &= ~(1<<indx);
21619 break;
21620 }
21621 case DMAPDATAFLAGS: //int32_t
21622 {
21623 DMaps[ri->dmapsref].flags = (value / 10000); break;
21624 }
21625 case DMAPDATAMIRRDMAP:
21626 {
21627 DMaps[ri->dmapsref].mirrorDMap = vbound(value / 10000, -1, MAXDMAPS); break;
21628 }
21629 case DMAPDATALOOPSTART:
21630 {
21631 DMaps[ri->dmapsref].tmusic_loop_start = value;
21632 if (ri->dmapsref == currdmap)
21633 {
21634 if (FFCore.doing_dmap_enh_music(currdmap))
21635 {
21636 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
21637 }
21638 }
21639 break;
21640 }
21641 case DMAPDATALOOPEND:
21642 {
21643 DMaps[ri->dmapsref].tmusic_loop_end = value;
21644 if (ri->dmapsref == currdmap)
21645 {
21646 if (FFCore.doing_dmap_enh_music(currdmap))
21647 {
21648 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
21649 }
21650 }
21651 break;
21652 }
21653 case DMAPDATAXFADEIN:
21654 {
21655 DMaps[ri->dmapsref].tmusic_xfade_in = (value / 10000);
21656 break;
21657 }
21658 case DMAPDATAXFADEOUT:
21659 {
21660 DMaps[ri->dmapsref].tmusic_xfade_out = (value / 10000);
21661 if (DMaps[currdmap].tmusic[0]!=0 && strcmp(DMaps[ri->dmapsref].tmusic, zcmusic->filename) == 0)
21662 {
21663 zcmusic->fadeoutframes = (value / 10000);
21664 }
21665 break;
21666 }
21667 case MUSICUPDATECOND:
21668 {
21669 FFCore.music_update_cond = vbound(value / 10000, 0, 255);
21670 break;
21671 }
21672 case MUSICUPDATEFLAGS:
21673 {
21674 int32_t indx = ri->d[rINDEX] / 10000;
21675 if (indx < 0 || indx > 1)
21676 {
21677 Z_scripterrlog("Invalid Index passed to Audio->MusicRefreshFlags[]: %d\n", indx);
21678 break;
21679 }
21680 SETFLAG(FFCore.music_update_flags, 1 << indx, value);
21681 break;
21682 }
21683 case DMAPDATAASUBSCRIPT: //byte
21684 {
21685 FFScript::deallocateAllArrays(ScriptType::ActiveSubscreen, ri->dmapsref);
21686 DMaps[ri->dmapsref].active_sub_script = vbound((value / 10000),0,NUMSCRIPTSDMAP-1); break;
21687 }
21688 case DMAPDATAMAPSCRIPT: //byte
21689 {
21690 3225 FFScript::deallocateAllArrays(ScriptType::OnMap, ri->dmapsref);
21691 3225 DMaps[ri->dmapsref].onmap_script = vbound((value / 10000),0,NUMSCRIPTSDMAP-1); break;
21692 }
21693 case DMAPDATAPSUBSCRIPT: //byte
21694 {
21695 FFScript::deallocateAllArrays(ScriptType::PassiveSubscreen, ri->dmapsref);
21696 word val = vbound((value / 10000),0,NUMSCRIPTSDMAP-1);
21697 if (FFCore.doscript(ScriptType::PassiveSubscreen) && ri->dmapsref == currdmap && val == DMaps[ri->dmapsref].passive_sub_script)
21698 break;
21699 DMaps[ri->dmapsref].passive_sub_script = val;
21700 if(ri->dmapsref == currdmap)
21701 {
21702 FFCore.doscript(ScriptType::PassiveSubscreen) = val != 0;
21703 };
21704 break;
21705 }
21706 case DMAPDATASUBINITD:
21707 {
21708 int32_t indx = ri->d[rINDEX] / 10000;
21709 if ( indx < 0 || indx > 7 )
21710 {
21711 Z_scripterrlog("Invalid index supplied to dmapdata->SubInitD[]: %d\n", indx); break;
21712 }
21713 else
21714 {
21715 DMaps[ri->dmapsref].sub_initD[indx] = value; break;
21716 }
21717 }
21718
21719 case DMAPDATAMAPINITD:
21720 {
21721 int32_t indx = ri->d[rINDEX] / 10000;
21722 if ( indx < 0 || indx > 7 )
21723 {
21724 Z_scripterrlog("Invalid index supplied to dmapdata->MapInitD[]: %d\n", indx); break;
21725 }
21726 else
21727 {
21728 DMaps[ri->dmapsref].onmap_initD[indx] = value; break;
21729 }
21730 }
21731
21732 case DMAPDATACHARTED:
21733 {
21734 int32_t scr = ri->d[rINDEX] / 10000;
21735 if(ri->dmapsref >= MAXDMAPS)
21736 {
21737 Z_scripterrlog("Invalid DMap reference used for dmapdata->Charted[]: %d\n", ri->dmapsref);
21738 }
21739 // else if((DMaps[get_currdmap()].type&dmfTYPE) == dmOVERW)
21740 // {
21741 // Z_scripterrlog("dmapdata->Charted[] cannot presently be used on Overworld-type dmaps\n");
21742 // }
21743 else if(((unsigned)(scr)) > 127)
21744 {
21745 Z_scripterrlog("Invalid index supplied to dmapdata->Charted[]: %d\n", scr);
21746 }
21747 else
21748 {
21749 int32_t col = (scr&15)-(DMaps[ri->dmapsref].type==dmOVERW ? 0 : DMaps[ri->dmapsref].xoff);
21750 if((DMaps[ri->dmapsref].type&dmfTYPE)!=dmOVERW ? (((unsigned)col) > 7) : (((unsigned)col) > 15))
21751 break; //Out-of-bounds; don't attempt write!
21752 int32_t di = (ri->dmapsref << 7) + (scr & 0x7F);
21753 game->bmaps[di] = (value/10000)&0x8F;
21754 }
21755 break;
21756 }
21757 //case DMAPDATAGRAVITY: //unimplemented
21758 //case DMAPDATAJUMPLAYER: //unimplemented
21759
21760 ///----------------------------------------------------------------------------------------------------//
21761 //messagedata msgd-> Variables
21762
21763
21764 case MESSAGEDATANEXT: //W
21765 {
21766 int32_t ID = ri->zmsgref;
21767
21768 if(BC::checkMessage(ID, "messagedata->Next") != SH::_NoError)
21769 break;
21770 else
21771 MsgStrings[ID].nextstring = vbound((value/10000), 0, (msg_count-1));
21772 break;
21773 }
21774
21775 case MESSAGEDATATILE: //W
21776 {
21777 int32_t ID = ri->zmsgref;
21778
21779 if(BC::checkMessage(ID, "messagedata->Tile") != SH::_NoError)
21780 break;
21781 else
21782 MsgStrings[ID].tile = vbound((value/10000), 0, (NEWMAXTILES));
21783 break;
21784 }
21785
21786 case MESSAGEDATACSET: //b
21787 {
21788 int32_t ID = ri->zmsgref;
21789
21790 if(BC::checkMessage(ID, "messagedata->CSet") != SH::_NoError)
21791 break;
21792 else
21793 MsgStrings[ID].cset = ((byte)vbound((value/10000), 0, 15));
21794 break;
21795 }
21796 case MESSAGEDATATRANS: //BOOL
21797 {
21798 int32_t ID = ri->zmsgref;
21799
21800 if(BC::checkMessage(ID, "messagedata->Transparent") != SH::_NoError)
21801 break;
21802 else
21803 (MsgStrings[ID].trans) = ((value)?true:false);
21804 break;
21805 }
21806 case MESSAGEDATAFONT: //B
21807 {
21808 int32_t ID = ri->zmsgref;
21809
21810 if(BC::checkMessage(ID, "messagedata->Font") != SH::_NoError)
21811 break;
21812 else
21813 MsgStrings[ID].font = ((byte)vbound((value/10000), 0, 255));
21814 break;
21815 }
21816 case MESSAGEDATAX: //SHORT
21817 {
21818 int32_t ID = ri->zmsgref;
21819
21820 if(BC::checkMessage(ID, "messagedata->X") != SH::_NoError)
21821 break;
21822 else
21823 MsgStrings[ID].x = ((int16_t)vbound((value/10000), SHRT_MIN, SHRT_MAX));
21824 break;
21825 }
21826 case MESSAGEDATAY: //SHORT
21827 {
21828 int32_t ID = ri->zmsgref;
21829
21830 if(BC::checkMessage(ID, "messagedata->Y") != SH::_NoError)
21831 break;
21832 else
21833 MsgStrings[ID].y = ((int16_t)vbound((value/10000), SHRT_MIN, SHRT_MAX));
21834 break;
21835 }
21836 case MESSAGEDATAW: //UNSIGNED SHORT
21837 {
21838 int32_t ID = ri->zmsgref;
21839
21840 if(BC::checkMessage(ID, "messagedata->Width") != SH::_NoError)
21841 break;
21842 else
21843 MsgStrings[ID].w = ((uint16_t)vbound((value/10000), 0, USHRT_MAX));
21844 break;
21845 }
21846 case MESSAGEDATAH: //UNSIGNED SHORT
21847 {
21848 int32_t ID = ri->zmsgref;
21849
21850 if(BC::checkMessage(ID, "messagedata->Height") != SH::_NoError)
21851 break;
21852 else
21853 MsgStrings[ID].h = ((uint16_t)vbound((value/10000), 0, USHRT_MAX));
21854 break;
21855 }
21856 case MESSAGEDATASFX: //BYTE
21857 {
21858 int32_t ID = ri->zmsgref;
21859
21860 if(BC::checkMessage(ID, "messagedata->Sound") != SH::_NoError)
21861 break;
21862 else
21863 MsgStrings[ID].sfx = ((byte)vbound((value/10000), 0, 255));
21864 break;
21865 }
21866 case MESSAGEDATALISTPOS: //WORD
21867 {
21868 int32_t ID = ri->zmsgref;
21869
21870 if(BC::checkMessage(ID, "messagedata->ListPosition") != SH::_NoError)
21871 break;
21872 else
21873 MsgStrings[ID].listpos = vbound((value/10000), 1, (msg_count-1));
21874 break;
21875 }
21876 case MESSAGEDATAVSPACE: //BYTE
21877 {
21878 int32_t ID = ri->zmsgref;
21879
21880 if(BC::checkMessage(ID, "messagedata->VSpace") != SH::_NoError)
21881 break;
21882 else
21883 MsgStrings[ID].vspace = ((byte)vbound((value/10000), 0, 255));
21884 break;
21885 }
21886 case MESSAGEDATAHSPACE: //BYTE
21887 {
21888 int32_t ID = ri->zmsgref;
21889
21890 if(BC::checkMessage(ID, "messagedata->HSpace") != SH::_NoError)
21891 break;
21892 else
21893 MsgStrings[ID].hspace = ((byte)vbound((value/10000), 0, 255));
21894 break;
21895 }
21896 case MESSAGEDATAFLAGS: //BYTE
21897 {
21898 int32_t ID = ri->zmsgref;
21899
21900 if(BC::checkMessage(ID, "messagedata->Flags") != SH::_NoError)
21901 break;
21902 else
21903 MsgStrings[ID].stringflags = ((byte)vbound((value/10000), 0, 255));
21904 break;
21905 }
21906 case MESSAGEDATAMARGINS: //BYTE, 4
21907 {
21908 int32_t indx = ri->d[rINDEX] / 10000;
21909 if ( indx < 0 || indx > 3 )
21910 {
21911 Z_scripterrlog("Invalid index supplied to messagedata->Margins[]: %d\n", indx);
21912 break;
21913 }
21914 int32_t ID = ri->zmsgref;
21915
21916 if(BC::checkMessage(ID, "messagedata->Margins[]") != SH::_NoError)
21917 break;
21918 else
21919 MsgStrings[ID].margins[indx] = ((byte)vbound((value/10000), 0, 255));
21920 break;
21921 }
21922 case MESSAGEDATAPORTTILE: //INT
21923 {
21924 int32_t ID = ri->zmsgref;
21925
21926 if(BC::checkMessage(ID, "messagedata->PortraitTile") != SH::_NoError)
21927 break;
21928 else
21929 MsgStrings[ID].portrait_tile = vbound((value/10000), 0, (NEWMAXTILES));
21930 break;
21931 }
21932 case MESSAGEDATAPORTCSET: //BYTE
21933 {
21934 int32_t ID = ri->zmsgref;
21935
21936 if(BC::checkMessage(ID, "messagedata->PortraitCSet") != SH::_NoError)
21937 break;
21938 else
21939 MsgStrings[ID].portrait_cset = ((byte)vbound((value/10000), 0, 15));
21940 break;
21941 }
21942 case MESSAGEDATAPORTX: //BYTE
21943 {
21944 int32_t ID = ri->zmsgref;
21945
21946 if(BC::checkMessage(ID, "messagedata->PortraitX") != SH::_NoError)
21947 break;
21948 else
21949 MsgStrings[ID].portrait_x = ((byte)vbound((value/10000), 0, 255));
21950 break;
21951 }
21952 case MESSAGEDATAPORTY: //BYTE
21953 {
21954 int32_t ID = ri->zmsgref;
21955
21956 if(BC::checkMessage(ID, "messagedata->PortraitY") != SH::_NoError)
21957 break;
21958 else
21959 MsgStrings[ID].portrait_y = ((byte)vbound((value/10000), 0, 255));
21960 break;
21961 }
21962 case MESSAGEDATAPORTWID: //BYTE
21963 {
21964 int32_t ID = ri->zmsgref;
21965
21966 if(BC::checkMessage(ID, "messagedata->PortraitTileWidth") != SH::_NoError)
21967 break;
21968 else
21969 MsgStrings[ID].portrait_tw = ((byte)vbound((value/10000), 0, 16));
21970 break;
21971 }
21972 case MESSAGEDATAPORTHEI: //BYTE
21973 {
21974 int32_t ID = ri->zmsgref;
21975
21976 if(BC::checkMessage(ID, "messagedata->PortraitTileHeight") != SH::_NoError)
21977 break;
21978 else
21979 MsgStrings[ID].portrait_th = ((byte)vbound((value/10000), 0, 14));
21980 break;
21981 }
21982 case MESSAGEDATAFLAGSARR: //BOOL, 7
21983 {
21984 int32_t indx = ri->d[rINDEX] / 10000;
21985 int32_t ID = ri->zmsgref;
21986
21987 if(BC::checkMessage(ID, "messagedata->Flags[]") != SH::_NoError)
21988 break;
21989 else
21990 {
21991 switch(indx)
21992 {
21993 case 0:
21994 (value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_WRAP : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_WRAP;
21995 break;
21996 case 1:
21997 (value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_CONT : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_CONT;
21998 break;
21999 case 2: //Not implemented
22000 //(value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_CENTER : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_CENTER;
22001 break;
22002 case 3: //Not implemented
22003 //(value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_RIGHT : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_RIGHT;
22004 break;
22005 case 4:
22006 (value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_FULLTILE : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_FULLTILE;
22007 break;
22008 case 5:
22009 (value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_TRANS_BG : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_TRANS_BG;
22010 break;
22011 case 6:
22012 (value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_TRANS_FG : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_TRANS_FG;
22013 break;
22014 default:
22015 Z_scripterrlog("Invalid index supplied to messagedata->Flags[]: %d\n", indx);
22016 break;
22017 }
22018 }
22019 break;
22020 }
22021
22022
22023
22024
22025 ///----------------------------------------------------------------------------------------------------//
22026 //combodata cd-> Setter Variables
22027 //newcombo
22028 #define SET_COMBO_VAR_INT(member, str) \
22029 { \
22030 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22031 { \
22032 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22033 } \
22034 else \
22035 { \
22036 combobuf[ri->combosref].member = vbound((value / 10000),0,214747); \
22037 } \
22038 } \
22039
22040 #define SET_COMBO_VAR_DWORD(member, str) \
22041 { \
22042 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22043 { \
22044 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22045 } \
22046 else \
22047 { \
22048 combobuf[ri->combosref].member = vbound((value / 10000),0,32767); \
22049 } \
22050 } \
22051
22052 #define SET_COMBO_VAR_BYTE(member, str) \
22053 { \
22054 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22055 { \
22056 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22057 } \
22058 else \
22059 { \
22060 combobuf[ri->combosref].member = vbound((value / 10000),0,255); \
22061 } \
22062 } \
22063
22064 #define SET_COMBO_VAR_INDEX(member, str, indexbound) \
22065 { \
22066 int32_t indx = ri->d[rINDEX] / 10000; \
22067 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22068 { \
22069 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22070 } \
22071 else if ( indx < 0 || indx >= indexbound ) \
22072 { \
22073 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
22074 } \
22075 else \
22076 { \
22077 combobuf[ri->combosref].member[indx] = vbound((value / 10000),0,214747); \
22078 } \
22079 }
22080
22081 #define SET_COMBO_VAR_INDEX2(member, str, indexbound, low, high) \
22082 { \
22083 int32_t indx = ri->d[rINDEX] / 10000; \
22084 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22085 { \
22086 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22087 } \
22088 else if ( indx < 0 || indx >= indexbound ) \
22089 { \
22090 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
22091 } \
22092 else \
22093 { \
22094 combobuf[ri->combosref].member[indx] = vbound((value / 10000),low,high); \
22095 } \
22096 }
22097
22098 #define SET_COMBO_BYTE_INDEX(member, str, indexbound) \
22099 { \
22100 int32_t indx = ri->d[rINDEX] / 10000; \
22101 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22102 { \
22103 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22104 } \
22105 else if ( indx < 0 || indx >= indexbound ) \
22106 { \
22107 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
22108 } \
22109 else \
22110 { \
22111 combobuf[ri->combosref].member[indx] = vbound((value / 10000),0,255); \
22112 } \
22113 }
22114
22115 #define SET_COMBO_FLAG(member, str) \
22116 { \
22117 int32_t flag = (value/10000); \
22118 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22119 { \
22120 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22121 } \
22122 else \
22123 { \
22124 if ( flag != 0 ) \
22125 { \
22126 combobuf[ri->combosref].member|=flag; \
22127 } \
22128 else combobuf[ri->combosref].member|= ~flag; \
22129 } \
22130 } \
22131
22132 //comboclass
22133 #define SET_COMBOCLASS_VAR_INT(member, str) \
22134 { \
22135 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22136 { \
22137 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22138 } \
22139 else \
22140 { \
22141 combo_class_buf[combobuf[ri->combosref].type].member = vbound((value / 10000),0,214747); \
22142 } \
22143 } \
22144
22145 #define SET_COMBOCLASS_VAR_DWORD(member, str) \
22146 { \
22147 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22148 { \
22149 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22150 } \
22151 else \
22152 { \
22153 combo_class_buf[combobuf[ri->combosref].type].member = vbound((value / 10000),0,32767); \
22154 } \
22155 } \
22156
22157 #define SET_COMBOCLASS_VAR_BYTE(member, str) \
22158 { \
22159 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22160 { \
22161 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22162 } \
22163 else \
22164 { \
22165 combo_class_buf[combobuf[ri->combosref].type].member = vbound((value / 10000),0,255); \
22166 } \
22167 } \
22168
22169 #define SET_COMBOCLASS_VAR_INDEX(member, str, indexbound) \
22170 { \
22171 int32_t indx = ri->d[rINDEX] / 10000; \
22172 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22173 { \
22174 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22175 } \
22176 else if ( indx < 0 || indx > indexbound ) \
22177 { \
22178 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
22179 } \
22180 else \
22181 { \
22182 combo_class_buf[combobuf[ri->combosref].type].member[indx] = vbound((value / 10000),0,214747); \
22183 } \
22184 }
22185
22186 #define SET_COMBOCLASS_BYTE_INDEX(member, str, indexbound) \
22187 { \
22188 int32_t indx = ri->d[rINDEX] / 10000; \
22189 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22190 { \
22191 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22192 } \
22193 else if ( indx < 0 || indx > indexbound ) \
22194 { \
22195 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
22196 } \
22197 else \
22198 { \
22199 combo_class_buf[combobuf[ri->combosref].type].member[indx] = vbound((value / 10000),0,255); \
22200 } \
22201 }
22202
22203 #define SET_COMBOCLASS_FLAG(member, str) \
22204 { \
22205 int32_t flag = (value/10000); \
22206 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22207 { \
22208 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22209 } \
22210 else \
22211 { \
22212 if ( flag != 0 ) \
22213 { \
22214 combo_class_buf[combobuf[ri->combosref].type].member|=flag; \
22215 } \
22216 else combo_class_buf[combobuf[ri->combosref].type].member|= ~flag; \
22217 } \
22218 } \
22219
22220 //NEWCOMBO STRUCT
22221 case COMBODTILE: SET_COMBO_VAR_INT(tile, "Tile"); break; //word
22222 case COMBODOTILE:
22223 {
22224 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22225 {
22226 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "OriginalTile");
22227 }
22228 else
22229 {
22230 newcombo& cdata = combobuf[ri->combosref];
22231 cdata.o_tile = vbound((value / 10000),0,NEWMAXTILES);
22232 if(get_qr(qr_NEW_COMBO_ANIMATION))
22233 {
22234 cdata.tile = cdata.o_tile + ((1+cdata.skipanim)*cdata.cur_frame);
22235 if(int32_t rowoffset = TILEROW(cdata.tile)-TILEROW(cdata.o_tile))
22236 {
22237 cdata.tile += cdata.skipanimy * rowoffset * TILES_PER_ROW;
22238 }
22239 }
22240 }
22241 break;
22242 }
22243 case COMBODFRAME: SET_COMBO_VAR_BYTE(cur_frame, "Frame"); break; //char
22244 case COMBODACLK: SET_COMBO_VAR_BYTE(aclk, "AClk"); break; //char
22245 case COMBODATASCRIPT: SET_COMBO_VAR_DWORD(script, "Script"); break; //word
22246 case COMBODASPEED: SET_COMBO_VAR_BYTE(speed, "ASpeed"); break; //char
22247 case COMBODFLIP: SET_COMBO_VAR_BYTE(flip, "Flip"); break; //char
22248 case COMBODWALK:
22249 {
22250 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22251 {
22252 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Walk");
22253 }
22254 else
22255 {
22256 combobuf[ri->combosref].walk &= ~0x0F;
22257 combobuf[ri->combosref].walk |= (value / 10000)&0x0F;
22258 }
22259 break;
22260 }
22261 case COMBODEFFECT:
22262 {
22263 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22264 {
22265 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Effect");
22266 }
22267 else
22268 {
22269 combobuf[ri->combosref].walk &= ~0xF0;
22270 combobuf[ri->combosref].walk |= ((value / 10000)&0x0F)<<4;
22271 }
22272 break;
22273 }
22274 case COMBODTYPE:
22275 {
22276 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22277 {
22278 Z_scripterrlog("Invalid Combo ID passed to combodata->Type: %d\n", (ri->combosref*10000));
22279 }
22280 else
22281 {
22282 screen_combo_modify_pre(ri->combosref);
22283 combobuf[ri->combosref].type = vbound((value / 10000),0,255);
22284 screen_combo_modify_post(ri->combosref);
22285 }
22286 break;
22287 }
22288 case COMBODCSET:
22289 {
22290 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22291 {
22292 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "CSet2");
22293 }
22294 else
22295 {
22296 int8_t v = vbound(value, -8, 7);
22297 combobuf[ri->combosref].csets &= ~0xF;
22298 combobuf[ri->combosref].csets |= v;
22299 }
22300 break;
22301 }
22302 case COMBODCSET2FLAGS:
22303 {
22304 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22305 {
22306 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "CSet2Flags");
22307 }
22308 else
22309 {
22310 combobuf[ri->combosref].csets &= 0xF;
22311 combobuf[ri->combosref].csets |= (value&0xF)<<4;
22312 }
22313 break;
22314 }
22315 case COMBODFOO: break; //W
22316 case COMBODFRAMES: SET_COMBO_VAR_BYTE(frames, "Frames"); break; //C
22317 case COMBODNEXTD: SET_COMBO_VAR_DWORD(speed, "NextData"); break; //W
22318 case COMBODNEXTC: SET_COMBO_VAR_BYTE(nextcombo, "NextCSet"); break; //C
22319 case COMBODFLAG: SET_COMBO_VAR_BYTE(nextcset, "Flag"); break; //C
22320 case COMBODSKIPANIM: SET_COMBO_VAR_BYTE(skipanim, "SkipAnim"); break; //C
22321 case COMBODNEXTTIMER: SET_COMBO_VAR_DWORD(nexttimer, "NextTimer"); break; //W
22322 case COMBODAKIMANIMY: SET_COMBO_VAR_BYTE(skipanimy, "SkipAnimY"); break; //C
22323 case COMBODANIMFLAGS: SET_COMBO_VAR_BYTE(animflags, "AnimFlags"); break; //C
22324 case COMBODEXPANSION: SET_COMBO_BYTE_INDEX(expansion, "Expansion[]", 6); break; //C , 6 INDICES
22325 case COMBODATTRIBUTES:
22326 {
22327 int32_t indx = ri->d[rINDEX] / 10000;
22328 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22329 {
22330 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Attributes[]");
22331 }
22332 else if ( indx < 0 || indx > 4 )
22333 {
22334 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "Attributes[]");
22335 }
22336 else
22337 {
22338 combobuf[ri->combosref].attributes[indx] = value;
22339 }
22340 }break;
22341 //case COMBODATAINITD: SET_COMBO_VAR_INDEX(initd, "InitD[]", 2); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
22342 case COMBODATAINITD:
22343 {
22344 int32_t indx = ri->d[rINDEX] / 10000;
22345 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22346 {
22347 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "InitD[]");
22348 }
22349 else if ( ((unsigned)indx) > 2 )
22350 {
22351 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "InitD[]");
22352 }
22353 else
22354 {
22355 combobuf[ri->combosref].initd[indx] = (value * ( get_qr(qr_COMBODATA_INITD_MULT_TENK) ? 10000 : 1));
22356 }
22357 break;
22358 }
22359
22360
22361 case COMBODATTRIBYTES: SET_COMBO_VAR_INDEX(attribytes, "Attribytes[]", 8); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
22362 case COMBODATTRISHORTS: SET_COMBO_VAR_INDEX2(attrishorts, "Attrishorts[]", 8, -32768, 32767); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
22363 case COMBODUSRFLAGARR:
22364 {
22365 int32_t indx = ri->d[rINDEX] / 10000;
22366 if (ri->combosref < 0 || ri->combosref >(MAXCOMBOS - 1))
22367 {
22368 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", "Flags[]", (ri->combosref * 10000));
22369 }
22370 else if (((unsigned)indx) > 15)
22371 {
22372 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", "Flags[]", indx);
22373 }
22374 else
22375 {
22376 SETFLAG(combobuf[ri->combosref].usrflags, 1 << indx, value);
22377 }
22378 break;
22379 }
22380 case COMBODGENFLAGARR:
22381 {
22382 int32_t indx = ri->d[rINDEX] / 10000;
22383 if (ri->combosref < 0 || ri->combosref >(MAXCOMBOS - 1))
22384 {
22385 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", "GenFlags[]", (ri->combosref * 10000));
22386 }
22387 else if (((unsigned)indx) > 0)
22388 {
22389 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", "GenFlags[]", indx);
22390 }
22391 else
22392 {
22393 SETFLAG(combobuf[ri->combosref].genflags, 1 << indx, value);
22394 }
22395 break;
22396 }
22397 case COMBODUSRFLAGS: SET_COMBO_VAR_INT(usrflags, "UserFlags"); break; //LONG
22398 case COMBODTRIGGERFLAGS: SET_COMBO_VAR_INDEX(triggerflags, "TriggerFlags[]", 6); break; //LONG 3 INDICES AS FLAGSETS
22399 case COMBODTRIGGERFLAGS2:
22400 {
22401 int32_t indx = ri->d[rINDEX] / 10000;
22402 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22403 {
22404 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TrigFlags[]");
22405 }
22406 else if ( unsigned(indx) >= 32*6 )
22407 {
22408 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "TrigFlags[]");
22409 }
22410 else
22411 {
22412 SETFLAG(combobuf[ri->combosref].triggerflags[indx/32],1<<(indx%32),value);
22413 }
22414 break;
22415 }
22416 case COMBODTRIGGERBUTTON:
22417 {
22418 int32_t indx = ri->d[rINDEX] / 10000;
22419 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22420 {
22421 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerButton[]");
22422 }
22423 else if ( unsigned(indx) >= 8 )
22424 {
22425 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "TriggerButton[]");
22426 }
22427 else
22428 {
22429 SETFLAG(combobuf[ri->combosref].triggerbtn,1<<indx,value);
22430 }
22431 break;
22432 }
22433 case COMBODTRIGGERITEM:
22434 {
22435 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22436 {
22437 Z_scripterrlog("Invalueid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerItem");
22438 }
22439 else combobuf[ri->combosref].triggeritem = vbound(value/10000,0,255);
22440 break;
22441 }
22442 case COMBODTRIGGERTIMER:
22443 {
22444 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22445 {
22446 Z_scripterrlog("Invalueid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerTimer");
22447 }
22448 else combobuf[ri->combosref].trigtimer = vbound(value/10000,0,255);
22449 break;
22450 }
22451 case COMBODTRIGGERSFX:
22452 {
22453 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22454 {
22455 Z_scripterrlog("Invalueid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerSFX");
22456 }
22457 else combobuf[ri->combosref].trigsfx = vbound(value/10000,0,255);
22458 break;
22459 }
22460 case COMBODTRIGGERCHANGECMB:
22461 {
22462 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22463 {
22464 Z_scripterrlog("Invalueid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerChange");
22465 }
22466 else combobuf[ri->combosref].trigchange = vbound(value/10000,-65535,65535);
22467 break;
22468 }
22469 case COMBODTRIGGERPROX:
22470 {
22471 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22472 {
22473 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerProximity");
22474 }
22475 else combobuf[ri->combosref].trigprox = vbound(value/10000,0,65535);
22476 break;
22477 }
22478 case COMBODTRIGGERLIGHTBEAM:
22479 {
22480 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22481 {
22482 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerLightBeam");
22483 }
22484 else combobuf[ri->combosref].triglbeam = vbound(value/10000,0,32);
22485 break;
22486 }
22487 case COMBODTRIGGERCTR:
22488 {
22489 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22490 {
22491 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerCounter");
22492 }
22493 else combobuf[ri->combosref].trigctr = vbound(value/10000, 0, MAX_COUNTERS-1);
22494 break;
22495 }
22496 case COMBODTRIGGERCTRAMNT:
22497 {
22498 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22499 {
22500 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerCtrAmount");
22501 }
22502 else combobuf[ri->combosref].trigctramnt = vbound(value/10000, -65535, 65535);
22503 break;
22504 }
22505
22506 case COMBODTRIGGERCOOLDOWN:
22507 {
22508 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22509 {
22510 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerCooldown: %d\n", (ri->combosref*10000));
22511 }
22512 else combobuf[ri->combosref].trigcooldown = vbound(value/10000, 0, 255);
22513 break;
22514 }
22515 case COMBODTRIGGERCOPYCAT:
22516 {
22517 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22518 {
22519 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerCopycat: %d\n", (ri->combosref*10000));
22520 }
22521 else combobuf[ri->combosref].trigcopycat = vbound(value/10000, 0, 255);
22522 break;
22523 }
22524 case COMBODTRIGITEMPICKUP:
22525 {
22526 const int32_t allowed_pflags = ipHOLDUP | ipTIMER | ipSECRETS | ipCANGRAB;
22527 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22528 {
22529 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerSpawnItemPickup: %d\n", (ri->combosref*10000));
22530 }
22531 else combobuf[ri->combosref].spawnip = (value/10000)&allowed_pflags;
22532 break;
22533 }
22534 case COMBODTRIGEXSTATE:
22535 {
22536 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22537 {
22538 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigExState: %d\n", (ri->combosref*10000));
22539 }
22540 else combobuf[ri->combosref].exstate = vbound(value/10000, -1, 31);
22541 break;
22542 }
22543 case COMBODTRIGSPAWNENEMY:
22544 {
22545 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22546 {
22547 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigSpawnEnemy: %d\n", (ri->combosref*10000));
22548 }
22549 else combobuf[ri->combosref].spawnenemy = vbound(value/10000, 0, 511);
22550 break;
22551 }
22552 case COMBODTRIGSPAWNITEM:
22553 {
22554 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22555 {
22556 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigSpawnItem: %d\n", (ri->combosref*10000));
22557 }
22558 else combobuf[ri->combosref].spawnitem = vbound(value/10000, -255, 255);
22559 break;
22560 }
22561 case COMBODTRIGCSETCHANGE:
22562 {
22563 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22564 {
22565 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigCSetChange: %d\n", (ri->combosref*10000));
22566 }
22567 else combobuf[ri->combosref].trigcschange = vbound(value/10000, -15, 15);
22568 break;
22569 }
22570 case COMBODLIFTGFXCOMBO:
22571 {
22572 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22573 {
22574 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXCombo: %d\n", (ri->combosref*10000));
22575 }
22576 else combobuf[ri->combosref].liftcmb = vbound(value/10000, 0, MAXCOMBOS);
22577 break;
22578 }
22579 case COMBODLIFTGFXCCSET:
22580 {
22581 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22582 {
22583 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXCSet: %d\n", (ri->combosref*10000));
22584 }
22585 else combobuf[ri->combosref].liftcs = vbound(value/10000, 0, 13);
22586 break;
22587 }
22588 case COMBODLIFTUNDERCMB:
22589 {
22590 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22591 {
22592 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftUnderCombo: %d\n", (ri->combosref*10000));
22593 }
22594 else combobuf[ri->combosref].liftundercmb = vbound(value/10000, 0, MAXCOMBOS);
22595 break;
22596 }
22597 case COMBODLIFTUNDERCS:
22598 {
22599 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22600 {
22601 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftUnderCSet: %d\n", (ri->combosref*10000));
22602 }
22603 else combobuf[ri->combosref].liftundercs = vbound(value/10000, 0, 13);
22604 break;
22605 }
22606 case COMBODLIFTDAMAGE:
22607 {
22608 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22609 {
22610 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftDamage: %d\n", (ri->combosref*10000));
22611 }
22612 else combobuf[ri->combosref].liftdmg = vbound(value/10000, 0, 255);
22613 break;
22614 }
22615 case COMBODLIFTLEVEL:
22616 {
22617 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22618 {
22619 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftLevel: %d\n", (ri->combosref*10000));
22620 }
22621 else combobuf[ri->combosref].liftlvl = vbound(value/10000, 0, 255);
22622 break;
22623 }
22624 case COMBODLIFTITEM:
22625 {
22626 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22627 {
22628 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftItem: %d\n", (ri->combosref*10000));
22629 }
22630 else combobuf[ri->combosref].liftitm = vbound(value/10000, 0, 255);
22631 break;
22632 }
22633 case COMBODLIFTFLAGS:
22634 {
22635 int32_t indx = ri->d[rINDEX] / 10000;
22636 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22637 {
22638 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftFlags[]: %d\n", (ri->combosref*10000));
22639 break;
22640 }
22641 if ( unsigned(indx) > 7 )
22642 {
22643 Z_scripterrlog("Invalid index supplied to combodata->LiftFlags[]: %d\n", indx);
22644 break;
22645 }
22646 SETFLAG(combobuf[ri->combosref].liftflags, (1<<indx), value);
22647 break;
22648 }
22649 case COMBODLIFTGFXTYPE:
22650 {
22651 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22652 {
22653 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXType: %d\n", (ri->combosref*10000));
22654 }
22655 else combobuf[ri->combosref].liftgfx = vbound(value/10000, 0, 2);
22656 break;
22657 }
22658 case COMBODLIFTGFXSPRITE:
22659 {
22660 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22661 {
22662 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXSprite: %d\n", (ri->combosref*10000));
22663 }
22664 else combobuf[ri->combosref].liftsprite = vbound(value/10000, 0, 255);
22665 break;
22666 }
22667 case COMBODLIFTSFX:
22668 {
22669 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22670 {
22671 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftSFX: %d\n", (ri->combosref*10000));
22672 }
22673 else combobuf[ri->combosref].liftsfx = vbound(value/10000, 0, 255);
22674 break;
22675 }
22676 case COMBODLIFTBREAKSPRITE:
22677 {
22678 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22679 {
22680 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftBreakSprite: %d\n", (ri->combosref*10000));
22681 }
22682 else combobuf[ri->combosref].liftbreaksprite = vbound(value/10000, -4, 255);
22683 break;
22684 }
22685 case COMBODLIFTBREAKSFX:
22686 {
22687 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22688 {
22689 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftBreakSFX: %d\n", (ri->combosref*10000));
22690 }
22691 else combobuf[ri->combosref].liftbreaksfx = vbound(value/10000, 0, 255);
22692 break;
22693 }
22694 case COMBODLIFTHEIGHT:
22695 {
22696 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22697 {
22698 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftHeight: %d\n", (ri->combosref*10000));
22699 }
22700 else combobuf[ri->combosref].lifthei = vbound(value/10000, 0, 255);
22701 break;
22702 }
22703 case COMBODLIFTTIME:
22704 {
22705 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22706 {
22707 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftTime: %d\n", (ri->combosref*10000));
22708 }
22709 else combobuf[ri->combosref].lifttime = vbound(value/10000, 0, 255);
22710 break;
22711 }
22712 case COMBODLIFTWEAPONITEM:
22713 {
22714 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22715 {
22716 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftWeaponItem: %d\n", (ri->combosref*10000));
22717 }
22718 else combobuf[ri->combosref].lift_parent_item = vbound(value/10000, 0, 255);
22719 break;
22720 }
22721 case COMBODTRIGGERLSTATE:
22722 {
22723 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22724 {
22725 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigLevelState: %d\n", (ri->combosref*10000));
22726 }
22727 else combobuf[ri->combosref].trig_lstate = vbound(value/10000, 0, 31);
22728 break;
22729 }
22730 case COMBODTRIGGERGSTATE:
22731 {
22732 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22733 {
22734 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGlobalState: %d\n", (ri->combosref*10000));
22735 }
22736 else combobuf[ri->combosref].trig_gstate = vbound(value/10000, 0, 255);
22737 break;
22738 }
22739 case COMBODTRIGGERGROUP:
22740 {
22741 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22742 {
22743 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGroup: %d\n", (ri->combosref*10000));
22744 }
22745 else combobuf[ri->combosref].trig_group = vbound(value/10000, 0, 255);
22746 break;
22747 }
22748 case COMBODTRIGGERGROUPVAL:
22749 {
22750 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22751 {
22752 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGroupVal: %d\n", (ri->combosref*10000));
22753 }
22754 else combobuf[ri->combosref].trig_group_val = vbound(value/10000, 0, 65535);
22755 break;
22756 }
22757 case COMBODTRIGGERGTIMER:
22758 {
22759 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22760 {
22761 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGStateTimer: %d\n", (ri->combosref*10000));
22762 }
22763 else combobuf[ri->combosref].trig_statetime = vbound(value/10000, 0, 214748);
22764 break;
22765 }
22766 case COMBODTRIGGERGENSCRIPT:
22767 {
22768 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22769 {
22770 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGenScript: %d\n", (ri->combosref*10000));
22771 }
22772 else combobuf[ri->combosref].trig_genscr = vbound(value/10000, 0, 65535);
22773 break;
22774 }
22775 case COMBODTRIGGERLEVEL: SET_COMBO_VAR_INT(triggerlevel, "TriggerLevel"); break; //LONG
22776
22777
22778
22779
22780
22781 //COMBOCLASS STRUCT
22782 //case COMBODNAME: //CHAR[64], STRING
22783 case COMBODBLOCKNPC: SET_COMBOCLASS_VAR_BYTE(block_enemies, "BlockNPC"); break; //C
22784 case COMBODBLOCKHOLE: SET_COMBOCLASS_VAR_BYTE(block_hole, "BlockHole"); break; //C
22785 case COMBODBLOCKTRIG: SET_COMBOCLASS_VAR_BYTE(block_trigger, "BlockTrigger"); break; //C
22786 case COMBODBLOCKWEAPON: SET_COMBOCLASS_BYTE_INDEX(block_weapon, "BlockWeapon[]", 32); break; //C, 32 INDICES
22787 case COMBODCONVXSPEED: SET_COMBOCLASS_VAR_DWORD(conveyor_x_speed, "ConveyorSpeedX"); break; //SHORT
22788 case COMBODCONVYSPEED: SET_COMBOCLASS_VAR_DWORD(conveyor_y_speed, "ConveyorSpeedY"); break; //SHORT
22789 case COMBODSPAWNNPC: SET_COMBOCLASS_VAR_DWORD(create_enemy, "SpawnNPC"); break; //W
22790 case COMBODSPAWNNPCWHEN: SET_COMBOCLASS_VAR_BYTE(create_enemy_when, "SpawnNPCWhen"); break; //C
22791 case COMBODSPAWNNPCCHANGE: SET_COMBOCLASS_VAR_INT(create_enemy_change, "SpawnNPCChange"); break; //LONG
22792 case COMBODDIRCHANGETYPE: SET_COMBOCLASS_VAR_BYTE(directional_change_type, "DirChange"); break; //C
22793 case COMBODDISTANCECHANGETILES: SET_COMBOCLASS_VAR_INT(distance_change_tiles, "DistanceChangeTiles"); break; //LONG
22794 case COMBODDIVEITEM: SET_COMBOCLASS_VAR_DWORD(dive_item, "DiveItem"); break; //SHORT
22795 case COMBODDOCK: SET_COMBOCLASS_VAR_BYTE(dock, "Dock"); break; //C
22796 case COMBODFAIRY: SET_COMBOCLASS_VAR_BYTE(fairy, "Fairy"); break; //C
22797 case COMBODFFATTRCHANGE: SET_COMBOCLASS_VAR_BYTE(ff_combo_attr_change, "FFCAttributeChange"); break; //C
22798 case COMBODFOORDECOTILE: SET_COMBOCLASS_VAR_INT(foot_decorations_tile, "DecorationTile"); break; //LONG
22799 case COMBODFOORDECOTYPE: SET_COMBOCLASS_VAR_BYTE(foot_decorations_type, "DecorationType"); break; //C
22800 case COMBODHOOKSHOTPOINT: SET_COMBOCLASS_VAR_BYTE(hookshot_grab_point, "Hookshot"); break; //C
22801 case COMBODLADDERPASS: SET_COMBOCLASS_VAR_BYTE(ladder_pass, "Ladder"); break; //C
22802 case COMBODLOCKBLOCK: SET_COMBOCLASS_VAR_BYTE(lock_block_type, "LockBlock"); break; //C
22803 case COMBODLOCKBLOCKCHANGE: SET_COMBOCLASS_VAR_INT(lock_block_change, "LockBlockChange"); break; //LONG
22804 case COMBODMAGICMIRROR: SET_COMBOCLASS_VAR_BYTE(magic_mirror_type, "Mirror"); break; //C
22805 case COMBODMODHPAMOUNT: SET_COMBOCLASS_VAR_DWORD(modify_hp_amount, "DamageAmount"); break; //SHORT
22806 case COMBODMODHPDELAY: SET_COMBOCLASS_VAR_BYTE(modify_hp_delay, "DamageDelay"); break; //C
22807 case COMBODMODHPTYPE: SET_COMBOCLASS_VAR_BYTE(modify_hp_type, "DamageType"); break; //C
22808 case COMBODNMODMPAMOUNT: SET_COMBOCLASS_VAR_DWORD(modify_mp_amount, "MagicAmount"); break; //SHORT
22809 case COMBODMODMPDELAY: SET_COMBOCLASS_VAR_BYTE(modify_mp_delay, "MagicDelay"); break; //C
22810 case COMBODMODMPTYPE: SET_COMBOCLASS_VAR_BYTE(modify_mp_type, "MagicType"); break; //C
22811 case COMBODNOPUSHBLOCK: SET_COMBOCLASS_VAR_BYTE(no_push_blocks, "NoPushBlocks"); break; //C
22812 case COMBODOVERHEAD: SET_COMBOCLASS_VAR_BYTE(overhead, "Overhead"); break; //C
22813 case COMBODPLACENPC: SET_COMBOCLASS_VAR_BYTE(place_enemy, "PlaceNPC"); break; //C
22814 case COMBODPUSHDIR: SET_COMBOCLASS_VAR_BYTE(push_direction, "PushDir"); break; //C
22815 case COMBODPUSHWAIT: SET_COMBOCLASS_VAR_BYTE(push_wait, "PushDelay"); break; //C
22816 case COMBODPUSHHEAVY: SET_COMBOCLASS_VAR_BYTE(push_weight, "PushHeavy"); break; //C
22817 case COMBODPUSHED: SET_COMBOCLASS_VAR_BYTE(pushed, "Pushed"); break; //C
22818 case COMBODRAFT: SET_COMBOCLASS_VAR_BYTE(raft, "Raft"); break; //C
22819 case COMBODRESETROOM: SET_COMBOCLASS_VAR_BYTE(reset_room, "ResetRoom"); break; //C
22820 case COMBODSAVEPOINTTYPE: SET_COMBOCLASS_VAR_BYTE(save_point_type, "SavePoint"); break; //C
22821 case COMBODSCREENFREEZETYPE: SET_COMBOCLASS_VAR_BYTE(screen_freeze_type, "FreezeScreen"); break; //C
22822 case COMBODSECRETCOMBO: SET_COMBOCLASS_VAR_BYTE(secret_combo, "SecretCombo"); break; //C
22823 case COMBODSINGULAR: SET_COMBOCLASS_VAR_BYTE(singular, "Singular"); break; //C
22824 case COMBODSLOWWALK: SET_COMBOCLASS_VAR_BYTE(slow_movement, "SlowWalk"); break; //C
22825 case COMBODSTATUETYPE: SET_COMBOCLASS_VAR_BYTE(statue_type, "Statue"); break; //C
22826 case COMBODSTEPTYPE: SET_COMBOCLASS_VAR_BYTE(step_type, "Step"); break; //C
22827 case COMBODSTEPCHANGEINTO: SET_COMBOCLASS_VAR_INT(step_change_to, "StepChange"); break; //LONG
22828 case COMBODSTRIKEWEAPONS: SET_COMBOCLASS_BYTE_INDEX(strike_weapons, "Strike[]", 32); break; //BYTE, 32 INDICES.
22829 case COMBODSTRIKEREMNANTS: SET_COMBOCLASS_VAR_INT(strike_remnants, "StrikeRemnants"); break; //LONG
22830 case COMBODSTRIKEREMNANTSTYPE: SET_COMBOCLASS_VAR_BYTE(strike_remnants_type, "StrikeRemnantsType"); break; //C
22831 case COMBODSTRIKECHANGE: SET_COMBOCLASS_VAR_INT(strike_change, "StrikeChange"); break; //LONG
22832 case COMBODSTRIKEITEM: SET_COMBOCLASS_VAR_DWORD(strike_item, "StrikeItem"); break; //SHORT
22833 case COMBODTOUCHITEM: SET_COMBOCLASS_VAR_DWORD(touch_item, "TouchItem"); break; //SHORT
22834 case COMBODTOUCHSTAIRS: SET_COMBOCLASS_VAR_BYTE(touch_stairs, "TouchStairs"); break; //C
22835 case COMBODTRIGGERTYPE: SET_COMBOCLASS_VAR_BYTE(trigger_type, "TriggerType"); break; //C
22836 case COMBODTRIGGERSENS: SET_COMBOCLASS_VAR_BYTE(trigger_sensitive, "TriggerSensitivity"); break; //C
22837 case COMBODWARPTYPE: SET_COMBOCLASS_VAR_BYTE(warp_type, "Warp"); break; //C
22838 case COMBODWARPSENS: SET_COMBOCLASS_VAR_BYTE(warp_sensitive, "WarpSensitivity"); break; //C
22839 case COMBODWARPDIRECT: SET_COMBOCLASS_VAR_BYTE(warp_direct, "WarpDirect"); break; //C
22840 case COMBODWARPLOCATION: SET_COMBOCLASS_VAR_BYTE(warp_location, "WarpLocation"); break; //C
22841 case COMBODWATER: SET_COMBOCLASS_VAR_BYTE(water, "Liquid"); break; //C
22842 case COMBODWHISTLE: SET_COMBOCLASS_VAR_BYTE(whistle, "Whistle"); break; //C
22843 case COMBODWINGAME: SET_COMBOCLASS_VAR_BYTE(win_game, "WinGame"); break; //C
22844 case COMBODBLOCKWPNLEVEL: SET_COMBOCLASS_VAR_BYTE(block_weapon_lvl, "BlockWeaponLevel"); break; //C
22845
22846
22847
22848 ///----------------------------------------------------------------------------------------------------//
22849 //npcdata nd-> Variables
22850
22851 #define SET_NPCDATA_VAR_INT(member, str) \
22852 { \
22853 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
22854 { \
22855 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
22856 } \
22857 else \
22858 { \
22859 guysbuf[ri->npcdataref].member = vbound((value / 10000),0,214747); \
22860 } \
22861 } \
22862
22863 #define SET_NPCDATA_VAR_DWORD(member, str) \
22864 { \
22865 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
22866 { \
22867 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
22868 } \
22869 else \
22870 { \
22871 guysbuf[ri->npcdataref].member = vbound((value / 10000),0,32767); \
22872 } \
22873 } \
22874
22875 #define SET_NPCDATA_VAR_BYTE(member, str) \
22876 { \
22877 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
22878 { \
22879 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
22880 } \
22881 else \
22882 { \
22883 guysbuf[ri->npcdataref].member = vbound((value / 10000),0,255); \
22884 } \
22885 } \
22886
22887 #define SET_NPCDATA_VAR_INDEX(member, str, indexbound) \
22888 { \
22889 int32_t indx = ri->d[rINDEX] / 10000; \
22890 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
22891 { \
22892 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
22893 } \
22894 else if ( (unsigned)indx > indexbound ) \
22895 { \
22896 Z_scripterrlog("Invalid Array Index passed to npcdata->%s: %d\n", indx, str); \
22897 } \
22898 else \
22899 { \
22900 guysbuf[ri->npcdataref].member[indx] = vbound((value / 10000),0,214747); \
22901 } \
22902 }
22903
22904 #define SET_NPCDATA_BYTE_INDEX(member, str, indexbound) \
22905 { \
22906 int32_t indx = ri->d[rINDEX] / 10000; \
22907 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
22908 { \
22909 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
22910 } \
22911 else if ( (unsigned)indx > indexbound ) \
22912 { \
22913 Z_scripterrlog("Invalid Array Index passed to npcdata->%s: %d\n", indx, str); \
22914 } \
22915 else \
22916 { \
22917 guysbuf[ri->npcdataref].member[indx] = vbound((value / 10000),0,255); \
22918 } \
22919 }
22920
22921 #define SET_NPCDATA_FLAG(member, str) \
22922 { \
22923 int32_t flag = (value/10000); \
22924 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
22925 { \
22926 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
22927 } \
22928 else \
22929 { \
22930 if ( flag ) \
22931 { \
22932 guysbuf[ri->npcdataref].member|=flag; \
22933 } \
22934 else guysbuf[ri->npcdataref].member|= ~flag; \
22935 } \
22936 } \
22937
22938 case NPCDATATILE: SET_NPCDATA_VAR_BYTE(tile, "Tile"); break;
22939 case NPCDATAWIDTH: SET_NPCDATA_VAR_BYTE(width, "Width"); break;
22940 case NPCDATAHEIGHT: SET_NPCDATA_VAR_BYTE(height, "Height"); break;
22941 case NPCDATAFLAGS: SET_NPCDATA_VAR_DWORD(flags, "Flags"); break; //16 b its
22942 case NPCDATAFLAGS2: SET_NPCDATA_VAR_DWORD(flags2, "Flags2"); break; //16 bits
22943 case NPCDATASTILE: SET_NPCDATA_VAR_BYTE(s_tile, "STile"); break;
22944 case NPCDATASWIDTH: SET_NPCDATA_VAR_BYTE(s_width, "SWidth"); break;
22945 case NPCDATASHEIGHT: SET_NPCDATA_VAR_BYTE(s_height, "SHeight"); break;
22946 case NPCDATAETILE: SET_NPCDATA_VAR_INT(e_tile, "ExTile"); break;
22947 case NPCDATAEWIDTH: SET_NPCDATA_VAR_BYTE(e_width, "ExWidth"); break;
22948 case NPCDATASCRIPT: SET_NPCDATA_VAR_BYTE(script, "Script"); break;
22949 case NPCDATAEHEIGHT: SET_NPCDATA_VAR_BYTE(e_height, "ExHeight"); break;
22950 case NPCDATAHP: SET_NPCDATA_VAR_DWORD(hp, "HP"); break;
22951 case NPCDATAFAMILY: SET_NPCDATA_VAR_DWORD(family, "Family"); break;
22952 case NPCDATACSET: SET_NPCDATA_VAR_DWORD(cset, "CSet"); break;
22953 case NPCDATAANIM: SET_NPCDATA_VAR_DWORD(anim, "Anim"); break;
22954 case NPCDATAEANIM: SET_NPCDATA_VAR_DWORD(e_anim, "ExAnim"); break;
22955 case NPCDATAFRAMERATE: SET_NPCDATA_VAR_DWORD(frate, "Framerate"); break;
22956 case NPCDATAEFRAMERATE: SET_NPCDATA_VAR_DWORD(e_frate, "ExFramerate"); break;
22957 case NPCDATATOUCHDAMAGE: SET_NPCDATA_VAR_DWORD(dp, "TouchDamage"); break;
22958 case NPCDATAWEAPONDAMAGE: SET_NPCDATA_VAR_DWORD(wdp, "WeaponDamage"); break;
22959 case NPCDATAWEAPON: SET_NPCDATA_VAR_DWORD(weapon, "Weapon"); break;
22960 case NPCDATARANDOM: SET_NPCDATA_VAR_DWORD(rate, "Random"); break;
22961 case NPCDATAHALT: SET_NPCDATA_VAR_DWORD(hrate, "Haltrate"); break;
22962 case NPCDATASTEP: SET_NPCDATA_VAR_DWORD(step, "Step"); break;
22963 case NPCDATAHOMING: SET_NPCDATA_VAR_DWORD(homing, "Homing"); break;
22964 case NPCDATAHUNGER: SET_NPCDATA_VAR_DWORD(grumble, "Hunger"); break;
22965 case NPCDATADROPSET: SET_NPCDATA_VAR_DWORD(item_set, "Dropset"); break;
22966 case NPCDATABGSFX: SET_NPCDATA_VAR_DWORD(bgsfx, "BGSFX"); break;
22967 case NPCDATADEATHSFX: SET_NPCDATA_VAR_BYTE(deadsfx, "DeathSFX"); break;
22968 case NPCDATAHITSFX: SET_NPCDATA_VAR_BYTE(hitsfx, "HitSFX"); break;
22969 case NPCDATAXOFS: SET_NPCDATA_VAR_INT(xofs, "DrawXOffset"); break;
22970 case NPCDATAYOFS: SET_NPCDATA_VAR_INT(yofs, "DrawYOffset"); break;
22971 case NPCDATAZOFS: SET_NPCDATA_VAR_INT(zofs, "DrawZOffset"); break;
22972 case NPCDATAHXOFS: SET_NPCDATA_VAR_INT(hxofs, "HitXOffset"); break;
22973 case NPCDATAHYOFS: SET_NPCDATA_VAR_INT(hyofs, "HitYOffset"); break;
22974 case NPCDATAHITWIDTH: SET_NPCDATA_VAR_INT(hxsz, "HitWidth"); break;
22975 case NPCDATAHITHEIGHT: SET_NPCDATA_VAR_INT(hysz, "HitHeight"); break;
22976 case NPCDATAHITZ: SET_NPCDATA_VAR_INT(hzsz, "HitZHeight"); break;
22977 case NPCDATATILEWIDTH: SET_NPCDATA_VAR_INT(txsz, "TileWidth"); break;
22978 case NPCDATATILEHEIGHT: SET_NPCDATA_VAR_INT(tysz, "TileHeight"); break;
22979 case NPCDATAWPNSPRITE: SET_NPCDATA_VAR_INT(wpnsprite, "WeaponSprite"); break;
22980 case NPCDATAWEAPONSCRIPT: SET_NPCDATA_VAR_INT(weaponscript, "WeaponScript"); break;
22981 case NPCDATADEFENSE: SET_NPCDATA_VAR_INDEX(defense, "Defense", 42); break;
22982 case NPCDATAWEAPONINITD: SET_NPCDATA_VAR_INDEX(weap_initiald, "WeaponInitD", 8); break;
22983 case NPCDATAINITD: SET_NPCDATA_VAR_INDEX(initD, "InitD", 8); break;
22984 case NPCDATASIZEFLAG: SET_NPCDATA_VAR_INT(SIZEflags, "SizeFlags"); break;
22985
22986 case NPCDATAFROZENTILE: SET_NPCDATA_VAR_INT(frozentile, "FrozenTile"); break;
22987 case NPCDATAFROZENCSET: SET_NPCDATA_VAR_INT(frozencset, "FrozenCSet"); break;
22988
22989 case NPCDATAATTRIBUTE:
22990 {
22991 int32_t indx = ri->d[rINDEX] / 10000;
22992 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
22993 {
22994 Z_scripterrlog("Invalid Sprite ID passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
22995 }
22996 else if ( indx < 0 || indx > MAX_NPC_ATRIBUTES )
22997 {
22998 Z_scripterrlog("Invalid Array Index passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
22999 }
23000 else
23001 {
23002 switch(indx)
23003 {
23004 case 0: guysbuf[ri->npcdataref].misc1 = (value / 10000); break;
23005 case 1: guysbuf[ri->npcdataref].misc2 = (value / 10000); break;
23006 case 2: guysbuf[ri->npcdataref].misc3 = (value / 10000); break;
23007 case 3: guysbuf[ri->npcdataref].misc4 = (value / 10000); break;
23008 case 4: guysbuf[ri->npcdataref].misc5 = (value / 10000); break;
23009 case 5: guysbuf[ri->npcdataref].misc6 = (value / 10000); break;
23010 case 6: guysbuf[ri->npcdataref].misc7 = (value / 10000); break;
23011 case 7: guysbuf[ri->npcdataref].misc8 = (value / 10000); break;
23012 case 8: guysbuf[ri->npcdataref].misc9 = (value / 10000); break;
23013 case 9: guysbuf[ri->npcdataref].misc10 = (value / 10000); break;
23014 case 10: guysbuf[ri->npcdataref].misc11 = (value / 10000); break;
23015 case 11: guysbuf[ri->npcdataref].misc12 = (value / 10000); break;
23016 case 12: guysbuf[ri->npcdataref].misc13 = (value / 10000); break;
23017 case 13: guysbuf[ri->npcdataref].misc14 = (value / 10000); break;
23018 case 14: guysbuf[ri->npcdataref].misc15 = (value / 10000); break;
23019
23020 case 15: guysbuf[ri->npcdataref].misc16 = value / 10000; break;
23021 case 16: guysbuf[ri->npcdataref].misc17 = value / 10000; break;
23022 case 17: guysbuf[ri->npcdataref].misc18 = value / 10000; break;
23023 case 18: guysbuf[ri->npcdataref].misc19 = value / 10000; break;
23024 case 19: guysbuf[ri->npcdataref].misc20 = value / 10000; break;
23025 case 20: guysbuf[ri->npcdataref].misc21 = value / 10000; break;
23026 case 21: guysbuf[ri->npcdataref].misc22 = value / 10000; break;
23027 case 22: guysbuf[ri->npcdataref].misc23 = value / 10000; break;
23028 case 23: guysbuf[ri->npcdataref].misc24 = value / 10000; break;
23029 case 24: guysbuf[ri->npcdataref].misc25 = value / 10000; break;
23030 case 25: guysbuf[ri->npcdataref].misc26 = value / 10000; break;
23031 case 26: guysbuf[ri->npcdataref].misc27 = value / 10000; break;
23032 case 27: guysbuf[ri->npcdataref].misc28 = value / 10000; break;
23033 case 28: guysbuf[ri->npcdataref].misc29 = value / 10000; break;
23034 case 29: guysbuf[ri->npcdataref].misc30 = value / 10000; break;
23035 case 30: guysbuf[ri->npcdataref].misc31 = value / 10000; break;
23036 case 31: guysbuf[ri->npcdataref].misc32 = value / 10000; break;
23037
23038 default:
23039 {
23040 Z_scripterrlog("Invalid Array Index passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
23041 break;
23042 }
23043 }
23044
23045 }
23046 break;
23047 }
23048
23049 case NPCDATABEHAVIOUR:
23050 {
23051 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
23052 {
23053 break;
23054 }
23055
23056
23057 int32_t index = vbound(ri->d[rINDEX]/10000,0,4);
23058 switch(index){
23059 case 0:
23060 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG1 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG1;
23061 break;
23062 case 1:
23063 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG2 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG2;
23064 break;
23065 case 2:
23066 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG3 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG3;
23067 break;
23068 case 3:
23069 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG4 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG4;
23070 break;
23071 case 4:
23072 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG5 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG5;
23073 break;
23074 case 5:
23075 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG6 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG6;
23076 break;
23077 case 6:
23078 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG7 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG7;
23079 break;
23080 case 7:
23081 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG8 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG8;
23082 break;
23083 case 8:
23084 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG9 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG9;
23085 break;
23086 case 9:
23087 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG10 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG10;
23088 break;
23089 case 10:
23090 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG11 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG11;
23091 break;
23092 case 11:
23093 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG12 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG12;
23094 break;
23095 case 12:
23096 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG13 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG13;
23097 break;
23098 case 13:
23099 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG14 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG14;
23100 break;
23101 case 14:
23102 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG15 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG15;
23103 break;
23104 case 15:
23105 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG16 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG16;
23106 break;
23107
23108
23109 default:
23110 break;
23111 }
23112
23113 break;
23114 }
23115
23116 case NPCDATASHIELD:
23117 {
23118 int32_t indx = ri->d[rINDEX] / 10000;
23119 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
23120 {
23121 Z_scripterrlog("Invalid NPC ID passed to npcdata->Shield[]: %d\n", (ri->npcdataref*10000));
23122 break;
23123 }
23124 else
23125 {
23126 switch(indx)
23127 {
23128 case 0:
23129 {
23130 (ri->d[rINDEX2])? (guysbuf[ri->npcdataref].flags |= inv_front) : (guysbuf[ri->npcdataref].flags &= ~inv_front);
23131 break;
23132 }
23133 case 1:
23134 {
23135 (ri->d[rINDEX2])? (guysbuf[ri->npcdataref].flags |= inv_left) : (guysbuf[ri->npcdataref].flags &= ~inv_left);
23136 break;
23137 }
23138 case 2:
23139 {
23140 (ri->d[rINDEX2])? (guysbuf[ri->npcdataref].flags |= inv_right) : (guysbuf[ri->npcdataref].flags &= ~inv_right);
23141 break;
23142 }
23143 case 3:
23144 {
23145 (ri->d[rINDEX2])? (guysbuf[ri->npcdataref].flags |= inv_back) : (guysbuf[ri->npcdataref].flags &= ~inv_back);
23146 break;
23147 }
23148 case 4:
23149 {
23150 (ri->d[rINDEX2])? (guysbuf[ri->npcdataref].flags |= guy_bkshield) : (guysbuf[ri->npcdataref].flags &= ~guy_bkshield);
23151 break;
23152 }
23153 default:
23154 {
23155 Z_scripterrlog("Invalid Array Index passed to npcdata->Shield[]: %d\n", indx);
23156 break;
23157 }
23158 }
23159 break;
23160 }
23161 }
23162
23163 case NPCDSHADOWSPR:
23164 {
23165 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
23166 {
23167 Z_scripterrlog("Invalid NPC ID passed to npcdata->ShadowSprite: %d\n", (ri->npcdataref*10000));
23168 }
23169 else
23170 {
23171 guysbuf[ri->npcdataref].spr_shadow = vbound(value/10000, 0, 255);
23172 }
23173 break;
23174 }
23175 case NPCDSPAWNSPR:
23176 {
23177 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
23178 {
23179 Z_scripterrlog("Invalid NPC ID passed to npcdata->SpawnSprite: %d\n", (ri->npcdataref*10000));
23180 }
23181 else
23182 {
23183 guysbuf[ri->npcdataref].spr_spawn = vbound(value/10000, 0, 255);
23184 }
23185 break;
23186 }
23187 case NPCDDEATHSPR:
23188 {
23189 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
23190 {
23191 Z_scripterrlog("Invalid NPC ID passed to npcdata->DeathSprite: %d\n", (ri->npcdataref*10000));
23192 }
23193 else
23194 {
23195 guysbuf[ri->npcdataref].spr_death = vbound(value/10000, 0, 255);
23196 }
23197 break;
23198 }
23199
23200
23201 ///----------------------------------------------------------------------------------------------------//
23202 //Dropset Variables
23203
23204 case DROPSETITEMS:
23205 {
23206 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
23207 {
23208 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
23209 break;
23210 }
23211 int32_t indx = ri->d[rINDEX]/10000;
23212 if(indx < 0 || indx > 9)
23213 {
23214 Z_scripterrlog("Invalid index passed to dropdata->Items[]: %d\n", indx);
23215 }
23216 else
23217 {
23218 item_drop_sets[ri->dropsetref].item[indx] = vbound(value / 10000, 0, MAXITEMS-1);
23219 }
23220 break;
23221 }
23222 case DROPSETCHANCES:
23223 {
23224 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
23225 {
23226 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
23227 break;
23228 }
23229 int32_t indx = ri->d[rINDEX]/10000;
23230 if(indx < 0 || indx > 9)
23231 {
23232 Z_scripterrlog("Invalid index passed to dropdata->Chances[]: %d\n", indx);
23233 }
23234 else
23235 {
23236 item_drop_sets[ri->dropsetref].chance[indx+1] = vbound((value / 10000),0,32767); //+1 is because '0' is 'nothing''s chance
23237 }
23238 break;
23239 }
23240 case DROPSETNULLCHANCE:
23241 {
23242 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
23243 {
23244 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
23245 break;
23246 }
23247 item_drop_sets[ri->dropsetref].chance[0] = vbound((value / 10000),0,32767);
23248 break;
23249 }
23250
23251 ///----------------------------------------------------------------------------------------------------//
23252 //Audio Variables
23253
23254 case AUDIOVOLUME:
23255 {
23256 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
23257 break;
23258
23259 int32_t indx = ri->d[rINDEX] / 10000;
23260 //zprint("Volume[index] is: %d", indx);
23261 //int32_t vol = value / 10000;
23262 //zprint("Attempted to change volume to: %d", vol);
23263 switch(indx)
23264 {
23265
23266 case 0: //midi volume
23267 {
23268 if ( !(FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME) )
23269 {
23270 FFCore.usr_midi_volume = FFScript::do_getMIDI_volume();
23271 FFCore.SetFFEngineFlag(FFCORE_SCRIPTED_MIDI_VOLUME,true);
23272 }
23273 FFScript::do_setMIDI_volume(value / 10000);
23274 break;
23275 }
23276 case 1: //digi volume
23277 {
23278 if ( !(FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME) )
23279 {
23280 FFCore.usr_digi_volume = FFScript::do_getDIGI_volume();
23281 FFCore.SetFFEngineFlag(FFCORE_SCRIPTED_DIGI_VOLUME,true);
23282 }
23283 FFScript::do_setDIGI_volume(value / 10000);
23284 break;
23285 }
23286 case 2: //emh music volume
23287 {
23288 if ( !(FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME) )
23289 {
23290 FFCore.usr_music_volume = FFScript::do_getMusic_volume();
23291 FFCore.SetFFEngineFlag(FFCORE_SCRIPTED_MUSIC_VOLUME,true);
23292 }
23293 FFScript::do_setMusic_volume(value / 10000);
23294 break;
23295 }
23296 case 3: //sfx volume
23297 {
23298 if ( !(FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME) )
23299 {
23300 FFCore.usr_sfx_volume = FFScript::do_getSFX_volume();
23301 FFCore.SetFFEngineFlag(FFCORE_SCRIPTED_SFX_VOLUME,true);
23302 }
23303 FFScript::do_setSFX_volume(value / 10000);
23304 break;
23305 }
23306 default:
23307 {
23308 Z_scripterrlog("Attempted to access an invalid index of Audio->Volume[]", indx);
23309 break;
23310 }
23311 }
23312 break;
23313 }
23314
23315 case AUDIOPAN:
23316 {
23317 if ( !(FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE) )
23318 {
23319 FFCore.usr_panstyle = FFScript::do_getSFX_pan();
23320 FFCore.SetFFEngineFlag(FFCORE_SCRIPTED_PANSTYLE,true);
23321 }
23322 FFScript::do_setSFX_pan(value/10000);
23323 break;
23324 }
23325
23326 ///----------------------------------------------------------------------------------------------------//
23327 //Graphics->
23328
23329 case NUMDRAWS:
23330 break;
23331
23332 case MAXDRAWS: break;
23333
23334 ///----------------------------------------------------------------------------------------------------//
23335 //Module->
23336 case MODULEGETSTR:
23337 {
23338 int32_t buf_pointer = ((ri->d[rINDEX])/10000);
23339 int32_t section_pointer = ((ri->d[rINDEX2])/10000);
23340 int32_t element_pointer = (value/10000);
23341
23342 string sectionid;
23343 string elementid;
23344
23345 ArrayH::getString(section_pointer, sectionid);
23346 ArrayH::getString(element_pointer, elementid);
23347
23348 char buffer[256] = {0};
23349
23350
23351 if(!fileexists((char*)moduledata.module_name))
23352 {
23353 Z_scripterrlog("I/O Error: No module definitions found when using Module->GetString()\n");
23354 }
23355 else
23356 {
23357 zc_push_config();
23358 //set config file
23359 zc_config_file(moduledata.module_name);
23360 strcpy(buffer,zc_get_config_basic(sectionid.c_str(), elementid.c_str(), ""));
23361 buffer[255] = '\0';
23362 if(ArrayH::setArray(buf_pointer, buffer) == SH::_Overflow)
23363 Z_scripterrlog("Dest string supplied to 'Module->GetString()' is not large enough\n");
23364 //return config file to zc.cfg
23365 zc_pop_config();
23366 }
23367
23368 break;
23369 }
23370
23371 ///----------------------------------------------------------------------------------------------------//
23372 //Misc./Internal
23373 case SP:
23374 ri->sp = value / 10000;
23375 ri->sp &= MASK_SP;
23376 break;
23377
23378 case PC:
23379 ri->pc = value;
23380 break;
23381
23382 case SWITCHKEY:
23383 ri->switchkey = value;
23384 break;
23385
23386 case SCRIPTRAM:
23387 case GLOBALRAM:
23388 455505918 ArrayH::setElement(ri->d[rINDEX] / 10000, ri->d[rINDEX2] / 10000, value);
23389 455505918 break;
23390
23391 case SCRIPTRAMD:
23392 case GLOBALRAMD:
23393 ArrayH::setElement(ri->d[rINDEX] / 10000, 0, value);
23394 break;
23395
23396 case REFFFC:
23397 503793138 ri->ffcref = value / 10000;
23398 503793138 break;
23399
23400 case REFITEM:
23401 409929 ri->itemref = value;
23402 409929 break;
23403
23404 case REFITEMCLASS:
23405 2162208 ri->idata = value;
23406 2162208 break;
23407
23408 case REFLWPN:
23409 10116373 ri->lwpn = value;
23410 10116373 break;
23411
23412 case REFEWPN:
23413 23554631 ri->ewpn = value;
23414 23554631 break;
23415
23416 case REFNPC:
23417 78110851 ri->guyref = value;
23418 78110851 break;
23419
23420 18561592 case REFMAPDATA: ri->mapsref = value; break;
23421 case REFSCREENDATA: ri->screenref = value; break;
23422 116558 case REFCOMBODATA: ri->combosref = value; break;
23423 64 case REFSPRITEDATA: ri->spritesref = value; break;
23424 265857 case REFBITMAP: ri->bitmapref = value; break;
23425 case REFNPCCLASS: ri->npcdataref = value; break;
23426
23427 805094 case REFDMAPDATA: ri->dmapsref = value; break;
23428 case REFSHOPDATA: ri->shopsref = value; break;
23429 case REFMSGDATA: ri->zmsgref = value; break;
23430 case REFUNTYPED: ri->untypedref = value; break;
23431
23432
23433 case REFDROPS: ri->dropsetref = value; break;
23434 case REFBOTTLETYPE: ri->bottletyperef = value; break;
23435 case REFBOTTLESHOP: ri->bottleshopref = value; break;
23436 142 case REFGENERICDATA: ri->genericdataref = value; break;
23437 case REFPONDS: ri->pondref = value; break;
23438 case REFWARPRINGS: ri->warpringref = value; break;
23439 case REFDOORS: ri->doorsref = value; break;
23440 case REFUICOLOURS: ri->zcoloursref = value; break;
23441 case REFRGB: ri->rgbref = value; break;
23442 case REFPALETTE: ri->paletteref = value; break;
23443 case REFTUNES: ri->tunesref = value; break;
23444 case REFPALCYCLE: ri->palcycleref = value; break;
23445 case REFGAMEDATA: ri->gamedataref = value; break;
23446 case REFCHEATS: ri->cheatsref = value; break;
23447 284 case REFFILE: ri->fileref = value; break;
23448 case REFDIRECTORY: ri->directoryref = value; break;
23449 case REFSTACK: ri->stackref = value; break;
23450 case REFSUBSCREEN: ri->subscreenref = value; break;
23451 303330 case REFRNG: ri->rngref = value; break;
23452 case CLASS_THISKEY: ri->thiskey = value; break;
23453 case CLASS_THISKEY2: ri->thiskey2 = value; break;
23454 case REFPALDATA: ri->paldataref = value; break;
23455
23456 //-------------------------------------------------------------------------------------------------
23457
23458 case PALDATACOLOR:
23459 {
23460 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->SetColor()"))
23461 {
23462 int32_t ind = ri->d[rINDEX] / 10000;
23463 if (unsigned(ind) >= PALDATA_NUM_COLORS)
23464 {
23465 Z_scripterrlog("Invalid color index (%d) passed to paldata->SetColor(). Valid indices are 0-255. Aborting.\n", ind);
23466 break;
23467 }
23468 int32_t clri = value;
23469
23470 RGB c = _RGB((clri >> 16) & 0xFF, (clri >> 8) & 0xFF, clri & 0xFF);
23471
23472 if (c.r < 0 || c.g < 0 || c.b < 0)
23473 {
23474 Z_scripterrlog("Invalid rgb (%d) passed to paldata->SetColor().\n", clri);
23475 }
23476 c.r = vbound(c.r, 0, 63);
23477 c.g = vbound(c.g, 0, 63);
23478 c.b = vbound(c.b, 0, 63);
23479
23480 pd->set_color(ind, c);
23481 }
23482 break;
23483 }
23484 case PALDATAR:
23485 FFCore.do_paldata_setrgb(0, value / 10000);
23486 break;
23487 case PALDATAG:
23488 FFCore.do_paldata_setrgb(1, value / 10000);
23489 break;
23490 case PALDATAB:
23491 FFCore.do_paldata_setrgb(2, value / 10000);
23492 break;
23493
23494 //-------------------------------------------------------------------------------------------------
23495
23496 case GENDATARUNNING:
23497 {
23498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "Running"))
23499 {
23500
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(value)
23501 58 scr->launch();
23502 else scr->quit();
23503 58 }
23504 58 break;
23505 }
23506 case GENDATASIZE:
23507 {
23508 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "DataSize"))
23509 {
23510 scr->dataResize(value/10000);
23511 }
23512 break;
23513 }
23514 case GENDATAEXITSTATE:
23515 {
23516 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "ExitState"))
23517 {
23518 size_t indx = ri->d[rINDEX]/10000;
23519 if(indx >= GENSCR_NUMST)
23520 {
23521 Z_scripterrlog("Invalid index passed to genericdata->ReloadState[]: %d\n", indx);
23522 break;
23523 }
23524 SETFLAG(scr->exitState, (1<<indx), value);
23525 }
23526 break;
23527 }
23528 case GENDATARELOADSTATE:
23529 {
23530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "ReloadState"))
23531 {
23532 74 size_t indx = ri->d[rINDEX]/10000;
23533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(indx >= GENSCR_NUMST)
23534 {
23535 Z_scripterrlog("Invalid index passed to genericdata->ReloadState[]: %d\n", indx);
23536 break;
23537 }
23538
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 SETFLAG(scr->reloadState, (1<<indx), value);
23539 74 }
23540 74 break;
23541 }
23542 case GENDATAEVENTSTATE:
23543 {
23544 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "EventListen"))
23545 {
23546 size_t indx = ri->d[rINDEX]/10000;
23547 if(indx >= GENSCR_NUMEVENT)
23548 {
23549 Z_scripterrlog("Invalid index passed to genericdata->EventListen[]: %d\n", indx);
23550 break;
23551 }
23552 SETFLAG(scr->eventstate, (1<<indx), value);
23553 }
23554 break;
23555 }
23556 case GENDATADATA:
23557 {
23558 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "Data[]"))
23559 {
23560 size_t indx = ri->d[rINDEX]/10000;
23561 if(indx >= scr->dataSize())
23562 {
23563 Z_scripterrlog("Invalid index passed to genericdata->Data[]: %d\n", indx);
23564 break;
23565 }
23566 scr->data[indx] = value;
23567 }
23568 break;
23569 }
23570 case GENDATAINITD:
23571 {
23572 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "InitD[]"))
23573 {
23574 size_t indx = ri->d[rINDEX]/10000;
23575 if(indx >= 8)
23576 {
23577 Z_scripterrlog("Invalid index passed to genericdata->InitD[]: %d\n", indx);
23578 break;
23579 }
23580 scr->initd[indx] = value;
23581 }
23582 break;
23583 }
23584
23585 //----------------------------------------------------------------------------------------------------//
23586
23587 case PORTALX:
23588 {
23589 if(portal* p = checkPortal(ri->portalref, "X"))
23590 p->x = zslongToFix(value);
23591 break;
23592 }
23593 case PORTALY:
23594 {
23595 if(portal* p = checkPortal(ri->portalref, "Y"))
23596 p->y = zslongToFix(value);
23597 break;
23598 }
23599 case PORTALDMAP:
23600 {
23601 if(portal* p = checkPortal(ri->portalref, "DMap"))
23602 p->destdmap = vbound(value/10000,-1,MAXDMAPS-1);
23603 break;
23604 }
23605 case PORTALSCREEN:
23606 {
23607 if(portal* p = checkPortal(ri->portalref, "Screen"))
23608 p->destscr = vbound(value/10000,0,255);
23609 break;
23610 }
23611 case PORTALACLK:
23612 {
23613 if(portal* p = checkPortal(ri->portalref, "AClk"))
23614 p->aclk = vbound(value/10000, 0, 9999);
23615 break;
23616 }
23617 case PORTALAFRM:
23618 {
23619 if(portal* p = checkPortal(ri->portalref, "AFrame"))
23620 p->aframe = vbound(value/10000, 0, 9999);
23621 break;
23622 }
23623 case PORTALOTILE:
23624 {
23625 if(portal* p = checkPortal(ri->portalref, "OriginalTile"))
23626 p->o_tile = vbound(value/10000, 0, NEWMAXTILES-1);
23627 break;
23628 }
23629 case PORTALASPD:
23630 {
23631 if(portal* p = checkPortal(ri->portalref, "ASpeed"))
23632 p->aspd = vbound(value/10000, 0, 9999);
23633 break;
23634 }
23635 case PORTALFRAMES:
23636 {
23637 if(portal* p = checkPortal(ri->portalref, "Frames"))
23638 p->frames = vbound(value/10000, 0, 9999);
23639 break;
23640 }
23641 case PORTALSAVED:
23642 {
23643 if(ri->portalref < 0 || value < 0) break;
23644 if(portal* p = checkPortal(ri->portalref, "SavedPortal"))
23645 {
23646 if(!value)
23647 p->saved_data = 0;
23648 else if(savedportal* sp = checkSavedPortal(value, "portal->SavedPortal"))
23649 p->saved_data = sp->getUID();
23650 }
23651 break;
23652 }
23653 case PORTALCLOSEDIS:
23654 {
23655 if(portal* p = checkPortal(ri->portalref, "CloseDisabled"))
23656 p->prox_active = value==0; //Inverted
23657 break;
23658 }
23659 case REFPORTAL:
23660 {
23661 ri->portalref = value;
23662 break;
23663 }
23664 case REFSAVPORTAL:
23665 {
23666 ri->saveportalref = value;
23667 break;
23668 }
23669 case PORTALWARPSFX:
23670 {
23671 if(portal* p = checkPortal(ri->portalref, "WarpSFX"))
23672 p->wsfx = vbound(value/10000,0,255);
23673 break;
23674 }
23675 case PORTALWARPVFX:
23676 {
23677 if(portal* p = checkPortal(ri->portalref, "WarpEffect"))
23678 p->weffect = vbound(value/10000,0,255);
23679 break;
23680 }
23681 case SAVEDPORTALX:
23682 {
23683 if(savedportal* p = checkSavedPortal(ri->saveportalref, "X"))
23684 p->x = value;
23685 break;
23686 }
23687 case SAVEDPORTALY:
23688 {
23689 if(savedportal* p = checkSavedPortal(ri->saveportalref, "Y"))
23690 p->y = value;
23691 break;
23692 }
23693 case SAVEDPORTALSRCDMAP:
23694 {
23695 if(savedportal* p = checkSavedPortal(ri->saveportalref, "SrcDMap"))
23696 p->srcdmap = vbound(value/10000, -1, MAXDMAPS-1);
23697 break;
23698 }
23699 case SAVEDPORTALDESTDMAP:
23700 {
23701 if(savedportal* p = checkSavedPortal(ri->saveportalref, "DestDMap"))
23702 p->destdmap = vbound(value/10000, -1, MAXDMAPS-1);
23703 break;
23704 }
23705 case SAVEDPORTALSRCSCREEN:
23706 {
23707 if(savedportal* p = checkSavedPortal(ri->saveportalref, "SrcScreen"))
23708 p->srcscr = vbound(value/10000,0,255);
23709 break;
23710 }
23711 case SAVEDPORTALDSTSCREEN:
23712 {
23713 if(savedportal* p = checkSavedPortal(ri->saveportalref, "DestScreen"))
23714 p->destscr = vbound(value/10000,0,255);
23715 break;
23716 }
23717 case SAVEDPORTALWARPSFX:
23718 {
23719 if(savedportal* p = checkSavedPortal(ri->saveportalref, "WarpSFX"))
23720 p->sfx = vbound(value/10000,0,255);
23721 break;
23722 }
23723 case SAVEDPORTALWARPVFX:
23724 {
23725 if(savedportal* p = checkSavedPortal(ri->saveportalref, "WarpEffect"))
23726 p->warpfx = vbound(value/10000,0,255);
23727 break;
23728 }
23729 case SAVEDPORTALSPRITE:
23730 {
23731 if(savedportal* p = checkSavedPortal(ri->saveportalref, "Sprite"))
23732 p->spr = vbound(value/10000,0,255);
23733 break;
23734 }
23735 case SAVEDPORTALPORTAL:
23736 {
23737 if(ri->saveportalref < 0 || value < 0) break;
23738 if(savedportal* sp = checkSavedPortal(ri->saveportalref, "Portal"))
23739 {
23740 int32_t id = getPortalFromSaved(sp);
23741 if(id == value) break; //no change
23742 portal* p = checkPortal(value,"savedportal->Portal");
23743 if(p)
23744 {
23745 p->saved_data = sp->getUID();
23746 if(id > 0)
23747 {
23748 portal* p = checkPortal(id,"THIS SHOULD NOT APPEAR");
23749 p->saved_data = 0;
23750 }
23751 }
23752 }
23753 break;
23754 }
23755
23756 default:
23757 {
23758
2/4
✓ Branch 0 taken 261880537 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 261880537 times.
261880537 if(arg >= D(0) && arg <= D(7)) ri->d[arg - D(0)] = value;
23759 else if(arg >= A(0) && arg <= A(1)) ri->a[arg - A(0)] = value;
23760 else if(arg >= GD(0) && arg <= GD(MAX_SCRIPT_REGISTERS)) game->global_d[arg-GD(0)] = value;
23761
23762 261880537 break;
23763 }
23764 }
23765 1401178716 } //end set_register
23766
23767 int32_t get_int_arr(const int32_t ptr, int32_t indx)
23768 {
23769 switch(ptr)
23770 {
23771 case INTARR_SCREEN_NPC:
23772 {
23773 if(BC::checkGuyIndex(indx, "Screen->NPCs[]") != SH::_NoError)
23774 return 0;
23775 return guys.spr(indx)->getUID();
23776 }
23777 case INTARR_SCREEN_ITEMSPR:
23778 {
23779 if(BC::checkItemIndex(indx, "Screen->Items[]") != SH::_NoError)
23780 return 0;
23781 return items.spr(indx)->getUID();
23782 }
23783 case INTARR_SCREEN_LWPN:
23784 {
23785 if(BC::checkLWeaponIndex(indx, "Screen->LWeapons[]") != SH::_NoError)
23786 return 0;
23787 return Lwpns.spr(indx)->getUID();
23788 }
23789 case INTARR_SCREEN_EWPN:
23790 {
23791 if(BC::checkEWeaponIndex(indx, "Screen->EWeapons[]") != SH::_NoError)
23792 return 0;
23793 return Ewpns.spr(indx)->getUID();
23794 }
23795 case INTARR_SCREEN_FFC:
23796 {
23797 if(BC::checkFFC(indx, "Screen->FFCs[]") != SH::_NoError)
23798 return 0;
23799 return indx*10000;
23800 }
23801 case INTARR_SCREEN_PORTALS:
23802 {
23803 if(BC::checkBoundsOneIndexed(indx, 0, portals.Count()-1, "Screen->Portals[]") != SH::_NoError)
23804 return 0;
23805 return portals.spr(indx)->getUID();
23806 }
23807 case INTARR_SAVPRTL:
23808 {
23809 if(BC::checkBoundsOneIndexed(indx, 0, game->user_portals.size()-1, "Game->SavedPortals[]") != SH::_NoError)
23810 return 0;
23811 return (indx+1)*10000;
23812 }
23813 default:
23814 {
23815 Z_scripterrlog("Unknown internal array '%d' read from!\n", ptr);
23816 return 0;
23817 }
23818 }
23819 }
23820 void set_int_arr(const int32_t ptr, int32_t indx, int32_t val)
23821 {
23822 switch(ptr)
23823 {
23824 case INTARR_SCREEN_NPC:
23825 Z_scripterrlog("Read-only array 'Screen->NPCs' cannot be written to!\n");
23826 return;
23827 case INTARR_SCREEN_ITEMSPR:
23828 Z_scripterrlog("Read-only array 'Screen->Items' cannot be written to!\n");
23829 return;
23830 case INTARR_SCREEN_LWPN:
23831 Z_scripterrlog("Read-only array 'Screen->LWeapons' cannot be written to!\n");
23832 return;
23833 case INTARR_SCREEN_EWPN:
23834 Z_scripterrlog("Read-only array 'Screen->EWeapons' cannot be written to!\n");
23835 return;
23836 case INTARR_SCREEN_FFC:
23837 Z_scripterrlog("Read-only array 'Screen->FFCs' cannot be written to!\n");
23838 return;
23839 case INTARR_SCREEN_PORTALS:
23840 Z_scripterrlog("Read-only array 'Screen->Portals' cannot be written to!\n");
23841 return;
23842 case INTARR_SAVPRTL:
23843 Z_scripterrlog("Read-only array 'Game->SavedPortals' cannot be written to!\n");
23844 return;
23845
23846 default:
23847 {
23848 Z_scripterrlog("Unknown internal array '%d' written to!\n", ptr);
23849 return;
23850 }
23851 }
23852 }
23853 int32_t sz_int_arr(const int32_t ptr)
23854 {
23855 switch(ptr)
23856 {
23857 case INTARR_SCREEN_NPC:
23858 {
23859 return guys.Count();
23860 }
23861 case INTARR_SCREEN_ITEMSPR:
23862 {
23863 return items.Count();
23864 }
23865 case INTARR_SCREEN_LWPN:
23866 {
23867 return Lwpns.Count();
23868 }
23869 case INTARR_SCREEN_EWPN:
23870 {
23871 return Ewpns.Count();
23872 }
23873 case INTARR_SCREEN_FFC:
23874 {
23875 return MAXFFCS;
23876 }
23877 case INTARR_SCREEN_PORTALS:
23878 {
23879 return portals.Count();
23880 }
23881 case INTARR_SAVPRTL:
23882 {
23883 return game->user_portals.size();
23884 }
23885 default:
23886 {
23887 Z_scripterrlog("Unknown internal array '%d' size read!\n", ptr);
23888 return -1;
23889 }
23890 }
23891 }
23892
23893 ///----------------------------------------------------------------------------------------------------//
23894 // ASM Functions //
23895 ///----------------------------------------------------------------------------------------------------//
23896
23897
23898 ///----------------------------------------------------------------------------------------------------//
23899 //Internal (to ZScript)
23900
23901 void do_set(const bool v, ScriptType whichType, const int32_t whichUID)
23902 {
23903 bool allowed = true;
23904 switch(whichType) //Check for objects attempting to change own script
23905 {
23906 //case ScriptType::Global:
23907
23908 case ScriptType::FFC:
23909 if(sarg1==FFSCRIPT && ri->ffcref==whichUID)
23910 allowed = false;
23911 break;
23912
23913 case ScriptType::Screen:
23914 if(sarg1==SCREENSCRIPT) //Only 1 screen script running at a time, no UID check needed
23915 allowed = false;
23916 break;
23917
23918 //case ScriptType::Player:
23919
23920 case ScriptType::Item:
23921 {
23922 bool collect = ( ( whichUID < 1 ) || (whichUID == COLLECT_SCRIPT_ITEM_ZERO) );
23923 int32_t new_UID = ( collect ) ? (( whichUID != COLLECT_SCRIPT_ITEM_ZERO ) ? (whichUID * -1) : 0) : whichUID;
23924
23925 if(collect)
23926 {
23927 if(sarg1==IDATAPSCRIPT && ri->idata==new_UID)
23928 allowed = false;
23929 }
23930 else if(sarg1==IDATASCRIPT && ri->idata==new_UID)
23931 allowed = false;
23932 break;
23933 }
23934
23935 case ScriptType::Lwpn:
23936 if(sarg1==LWPNSCRIPT && ri->lwpn==whichUID)
23937 allowed = false;
23938 break;
23939
23940 case ScriptType::NPC:
23941 if(sarg1==NPCSCRIPT && ri->guyref==whichUID)
23942 allowed = false;
23943 break;
23944
23945 //case ScriptType::Subscreen:
23946
23947 case ScriptType::Ewpn:
23948 if(sarg1==EWPNSCRIPT && ri->ewpn==whichUID)
23949 allowed = false;
23950 break;
23951
23952 case ScriptType::DMap:
23953 if(sarg1==DMAPSCRIPT && ri->dmapsref==whichUID)
23954 allowed = false;
23955 break;
23956
23957 case ScriptType::ItemSprite:
23958 if(sarg1==ITEMSPRITESCRIPT && ri->itemref==whichUID)
23959 allowed = false;
23960 break;
23961 }
23962 if(!allowed)
23963 {
23964 Z_scripterrlog("Script attempted to change own object's script! This has been ignored.\n");
23965 return;
23966 }
23967 int32_t temp = SH::get_arg(sarg2, v);
23968 set_register(sarg1, temp);
23969 }
23970
23971 void do_push(const bool v)
23972 {
23973 const int32_t value = SH::get_arg(sarg1, v);
23974 --ri->sp;
23975 ri->sp &= MASK_SP;
23976 SH::write_stack(ri->sp, value);
23977 }
23978 57459 void do_push_varg(const bool v)
23979 {
23980 57459 const int32_t value = SH::get_arg(sarg1, v);
23981 57459 zs_vargs.push_back(value);
23982 57459 }
23983
23984 void do_pop()
23985 {
23986 const int32_t value = SH::read_stack(ri->sp);
23987 ++ri->sp;
23988 ri->sp &= MASK_SP;
23989 set_register(sarg1, value);
23990 }
23991
23992 58814 void do_peek()
23993 {
23994 58814 set_register(sarg1, SH::read_stack(ri->sp));
23995 58814 }
23996
23997 void do_pops() // Pop past a bunch of stuff at once. Useful for clearing the stack.
23998 {
23999 int32_t num = sarg2;
24000 ri->sp += num;
24001 ri->sp &= MASK_SP;
24002 word read = (ri->sp-1) & MASK_SP;
24003 int32_t value = SH::read_stack(read);
24004 set_register(sarg1, value);
24005 }
24006
24007 void do_loadi()
24008 {
24009 const int32_t stackoffset = get_register(sarg2) / 10000;
24010 const int32_t value = SH::read_stack(stackoffset);
24011 set_register(sarg1, value);
24012 }
24013
24014 void do_storei()
24015 {
24016 const int32_t stackoffset = get_register(sarg2) / 10000;
24017 const int32_t value = get_register(sarg1);
24018 SH::write_stack(stackoffset, value);
24019 }
24020
24021 void do_loadd()
24022 {
24023 const int32_t stackoffset = (sarg2+ri->d[rSFRAME]) / 10000;
24024 const int32_t value = SH::read_stack(stackoffset);
24025 set_register(sarg1, value);
24026 }
24027
24028 void do_stored()
24029 {
24030 const int32_t stackoffset = (sarg2+ri->d[rSFRAME]) / 10000;
24031 const int32_t value = get_register(sarg1);
24032 SH::write_stack(stackoffset, value);
24033 }
24034
24035 void do_enqueue(const bool)
24036 {
24037 }
24038 void do_dequeue(const bool)
24039 {
24040 }
24041
24042 void do_comp(bool v, const bool inv = false)
24043 {
24044 bool v2 = false;
24045 if(inv) zc_swap(v,v2);
24046 int32_t temp = SH::get_arg(sarg2, v);
24047 int32_t temp2 = SH::get_arg(sarg1, v2);
24048
24049 if(temp2 >= temp) ri->scriptflag |= MOREFLAG;
24050 else ri->scriptflag &= ~MOREFLAG;
24051
24052 if(temp2 == temp) ri->scriptflag |= TRUEFLAG;
24053 else ri->scriptflag &= ~TRUEFLAG;
24054 }
24055
24056 void do_internal_strcmp()
24057 {
24058 int32_t arrayptr_a = get_register(sarg1)/10000;
24059 int32_t arrayptr_b = get_register(sarg2)/10000;
24060 string strA;
24061 string strB;
24062 ArrayH::getString(arrayptr_a, strA);
24063 ArrayH::getString(arrayptr_b, strB);
24064 int32_t temp = strcmp(strA.c_str(), strB.c_str());
24065
24066 if(temp >= 0) ri->scriptflag |= MOREFLAG;
24067 else ri->scriptflag &= ~MOREFLAG;
24068
24069 if(temp == 0) ri->scriptflag |= TRUEFLAG;
24070 else ri->scriptflag &= ~TRUEFLAG;
24071 }
24072
24073 void do_internal_stricmp()
24074 {
24075 int32_t arrayptr_a = get_register(sarg1)/10000;
24076 int32_t arrayptr_b = get_register(sarg2)/10000;
24077 string strA;
24078 string strB;
24079 ArrayH::getString(arrayptr_a, strA);
24080 ArrayH::getString(arrayptr_b, strB);
24081 int32_t temp = stricmp(strA.c_str(), strB.c_str());
24082
24083 if(temp >= 0) ri->scriptflag |= MOREFLAG;
24084 else ri->scriptflag &= ~MOREFLAG;
24085
24086 if(temp == 0) ri->scriptflag |= TRUEFLAG;
24087 else ri->scriptflag &= ~TRUEFLAG;
24088 }
24089
24090 void do_resize_array()
24091 {
24092 int32_t size = vbound(get_register(sarg2) / 10000, 1, 214748);
24093 dword ptrval = get_register(sarg1) / 10000;
24094 ArrayManager am(ptrval);
24095 am.resize(size);
24096 }
24097
24098 void do_own_array(dword arrindx, ScriptType scriptType, const int32_t UID)
24099 {
24100 ArrayManager am(arrindx);
24101
24102 if(am.internal())
24103 {
24104 Z_scripterrlog("Cannot 'OwnArray()' an internal array '%d'\n", arrindx);
24105 return;
24106 }
24107 if(arrindx >= NUM_ZSCRIPT_ARRAYS && arrindx < NUM_ZSCRIPT_ARRAYS*2)
24108 {
24109 //ignore global arrays
24110 }
24111 else if(!am.invalid())
24112 {
24113 if(arrindx > 0 && arrindx < NUM_ZSCRIPT_ARRAYS)
24114 {
24115 arrayOwner[arrindx].scriptType = scriptType;
24116 arrayOwner[arrindx].ownerUID = UID;
24117 arrayOwner[arrindx].specOwned = true;
24118 arrayOwner[arrindx].specCleared = false;
24119 }
24120 else if(arrindx < 0) //object array
24121 Z_scripterrlog("Cannot 'OwnArray()' an object-based array '%d'\n", arrindx);
24122 }
24123 else Z_scripterrlog("Tried to 'OwnArray()' an invalid array '%d'\n", arrindx);
24124 }
24125 void do_destroy_array()
24126 {
24127 dword arrindx = get_register(sarg1) / 10000;
24128
24129 ArrayManager am(arrindx);
24130
24131 if(am.internal())
24132 {
24133 Z_scripterrlog("Cannot 'DestroyArray()' an internal array '%d'\n", arrindx);
24134 return;
24135 }
24136
24137 if(arrindx >= NUM_ZSCRIPT_ARRAYS && arrindx < NUM_ZSCRIPT_ARRAYS*2)
24138 {
24139 //ignore global arrays
24140 }
24141 else if(!am.invalid())
24142 {
24143 if(arrindx > 0 && arrindx < NUM_ZSCRIPT_ARRAYS)
24144 {
24145 arrayOwner[arrindx].clear();
24146
24147 if(localRAM[arrindx].Size() == 0)
24148 ;
24149 else
24150 {
24151 localRAM[arrindx].Clear();
24152 }
24153 arrayOwner[arrindx].specCleared = true;
24154 }
24155 else if(arrindx < 0) //object array
24156 Z_scripterrlog("Cannot 'DestroyArray()' an object-based array '%d'\n", arrindx);
24157 }
24158 else Z_scripterrlog("Tried to 'DestroyArray()' an invalid array '%d'\n", arrindx);
24159 }
24160
24161 7021440 void do_allocatemem(const bool v, const bool local, ScriptType type, const uint32_t UID)
24162 {
24163 7021440 const int32_t size = SH::get_arg(sarg2, v) / 10000;
24164 dword ptrval;
24165
24166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7021440 times.
7021440 if(size <= 0)
24167 {
24168 Z_scripterrlog("Array initialized to invalid size of %d\n", size);
24169 set_register(sarg1, 0); //Pass back NULL
24170 return;
24171 }
24172
24173
2/2
✓ Branch 0 taken 7021113 times.
✓ Branch 1 taken 327 times.
7021440 if(local)
24174 {
24175 //localRAM[0] is used as an invalid container, so 0 can be the NULL pointer in ZScript
24176
2/2
✓ Branch 0 taken 383579577 times.
✓ Branch 1 taken 7021113 times.
390600690 for(ptrval = 1; localRAM[ptrval].Size() != 0; ptrval++) ;
24177
24178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7021113 times.
7021113 if(ptrval >= NUM_ZSCRIPT_ARRAYS)
24179 {
24180 Z_scripterrlog("%d local arrays already in use, no more can be allocated\n", NUM_ZSCRIPT_ARRAYS-1);
24181 ptrval = 0;
24182 }
24183 else
24184 {
24185 7021113 ZScriptArray &a = localRAM[ptrval]; //marginally faster for large arrays if we use a reference
24186
24187 7021113 a.Resize(size);
24188
24189
2/2
✓ Branch 0 taken 109296253 times.
✓ Branch 1 taken 7021113 times.
116317366 for(dword j = 0; j < (dword)size; j++)
24190 109296253 a[j] = 0; //initialize array
24191
24192 // Keep track of which object created the array so we know which to deallocate
24193 //Z_eventlog("Allocating array %d to script %s, %d\n", ptrval, script_types[type], UID);
24194 7021113 arrayOwner[ptrval].scriptType = type;
24195 7021113 arrayOwner[ptrval].ownerUID = UID;
24196 7021113 arrayOwner[ptrval].specOwned = false;
24197 7021113 arrayOwner[ptrval].specCleared = false;
24198 }
24199 7021113 }
24200 else
24201 {
24202 //Globals are only allocated here at first play, otherwise in init_game
24203
2/2
✓ Branch 0 taken 5772 times.
✓ Branch 1 taken 327 times.
6099 for(ptrval = 0; game->globalRAM[ptrval].Size() != 0; ptrval++) ;
24204
24205
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(ptrval >= game->globalRAM.size())
24206 {
24207 al_trace("Invalid pointer value of %u passed to global allocate\n", ptrval);
24208 //this shouldn't happen, unless people are putting ALLOCATEGMEM in their ZASM scripts where they shouldn't be
24209 }
24210
24211 327 ZScriptArray &a = game->globalRAM[ptrval];
24212
24213 327 a.Resize(size);
24214
24215
2/2
✓ Branch 0 taken 538590 times.
✓ Branch 1 taken 327 times.
538917 for(dword j = 0; j < (dword)size; j++)
24216 538590 a[j] = 0;
24217
24218 327 ptrval += NUM_ZSCRIPT_ARRAYS; //so each pointer has a unique value
24219 }
24220
24221
24222 7021440 set_register(sarg1, ptrval * 10000);
24223
24224 // If this happens once per frame, it can drown out every other message. -L
24225 /*Z_eventlog("Allocated %s array of size %d, pointer address %ld\n",
24226 local ? "local": "global", size, ptrval);*/
24227 7021440 }
24228
24229 6996587 void do_deallocatemem()
24230 {
24231 6996587 const int32_t ptrval = get_register(sarg1) / 10000;
24232
24233 6996587 FFScript::deallocateZScriptArray(ptrval);
24234 6996587 }
24235
24236 void do_loada(const byte a)
24237 {
24238 if(ri->a[a] == 0)
24239 {
24240 Z_eventlog("Global scripts currently have no A registers\n");
24241 return;
24242 }
24243
24244 int32_t ffcref = (ri->a[a] / 10000) - 1; //FFC 2
24245
24246 if(BC::checkFFC(ffcref, "LOAD%i") != SH::_NoError)
24247 return;
24248
24249 int32_t reg = get_register(sarg2); //Register in FFC 2
24250
24251 if(reg >= D(0) && reg <= D(7))
24252 set_register(sarg1, FFCore.ref(ScriptType::FFC, ffcref).d[reg - D(0)]); //get back the info into *sarg1
24253 else if(reg == A(0) || reg == A(1))
24254 set_register(sarg1, FFCore.ref(ScriptType::FFC, ffcref).a[reg - A(0)]);
24255 else if(reg == SP)
24256 set_register(sarg1, FFCore.ref(ScriptType::FFC, ffcref).sp * 10000);
24257
24258 //Can get everything else using REFFFC
24259 }
24260
24261 void do_seta(const byte a)
24262 {
24263 if(ri->a[a] == 0)
24264 {
24265 Z_eventlog("Global scripts currently have no A registers\n");
24266 return;
24267 }
24268
24269 int32_t ffcref = (ri->a[a] / 10000) - 1; //FFC 2
24270
24271 if(BC::checkFFC(ffcref, "SETA%i") != SH::_NoError)
24272 return;
24273
24274 int32_t reg = get_register(sarg2); //Register in FFC 2
24275
24276 if(reg >= D(0) && reg <= D(7))
24277 FFCore.ref(ScriptType::FFC, ffcref).d[reg - D(0)] = get_register(sarg1); //Set it to *sarg1
24278 else if(reg == A(0) || reg == A(1))
24279 FFCore.ref(ScriptType::FFC, ffcref).a[reg - A(0)] = get_register(sarg1);
24280 else if(reg == SP)
24281 FFCore.ref(ScriptType::FFC, ffcref).sp = get_register(sarg1) / 10000;
24282 }
24283
24284 ///----------------------------------------------------------------------------------------------------//
24285 //Mathematical
24286
24287 void do_add(const bool v)
24288 {
24289 int32_t temp = SH::get_arg(sarg2, v);
24290 int32_t temp2 = get_register(sarg1);
24291
24292 set_register(sarg1, temp2 + temp);
24293 }
24294
24295 void do_sub(bool v, const bool inv = false)
24296 {
24297 bool v2 = false;
24298 if(inv) zc_swap(v,v2);
24299 auto destreg = (inv ? sarg2 : sarg1);
24300 int32_t temp = SH::get_arg(sarg2, v);
24301 int32_t temp2 = SH::get_arg(sarg1, v2);
24302 //zprint2("Subtraction found: '%d - %d' where '%s - %s'\n", temp2, temp, v2 ? "const" : "reg", v ? "const" : "reg");
24303 set_register(destreg, temp2 - temp);
24304 }
24305
24306 void do_mult(const bool v)
24307 {
24308 int64_t temp = SH::get_arg(sarg2, v);
24309 int32_t temp2 = get_register(sarg1);
24310
24311 set_register(sarg1, int32_t((temp * temp2) / 10000));
24312 }
24313
24314 930 void do_div(bool v, const bool inv = false)
24315 {
24316 930 bool v2 = false;
24317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 930 times.
930 if(inv) zc_swap(v,v2);
24318
1/2
✓ Branch 0 taken 930 times.
✗ Branch 1 not taken.
930 auto destreg = (inv ? sarg2 : sarg1);
24319 930 int64_t temp = SH::get_arg(sarg2, v);
24320 930 int64_t temp2 = SH::get_arg(sarg1, v2);
24321
24322
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 918 times.
930 if(temp == 0)
24323 {
24324 12 Z_scripterrlog("Script attempted to divide %ld by zero!\n", temp2);
24325 12 set_register(destreg, int32_t(sign(temp2) * MAX_SIGNED_32));
24326 12 }
24327 else
24328 {
24329 918 set_register(destreg, int32_t((temp2 * 10000) / temp));
24330 }
24331 930 }
24332
24333 252 void do_mod(bool v, const bool inv = false)
24334 {
24335 252 bool v2 = false;
24336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(inv) zc_swap(v,v2);
24337
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 auto destreg = (inv ? sarg2 : sarg1);
24338 252 int32_t temp = SH::get_arg(sarg2, v);
24339 252 int32_t temp2 = SH::get_arg(sarg1, v2);
24340
24341
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 240 times.
252 if(temp == 0)
24342 {
24343 12 Z_scripterrlog("Script attempted to modulo %ld by zero!\n",temp2);
24344 12 temp = 1;
24345 12 }
24346
24347 252 set_register(destreg, temp2 % temp);
24348 252 }
24349
24350 9368395 void do_trig(const bool v, const byte type)
24351 {
24352 9368395 double rangle = (SH::get_arg(sarg2, v) / 10000.0) * PI / 180.0;
24353
24354
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6163735 times.
✓ Branch 2 taken 3204584 times.
✓ Branch 3 taken 76 times.
9368395 switch(type)
24355 {
24356 case 0:
24357 6163735 set_register(sarg1, int32_t(zc::math::Sin(rangle) * 10000.0));
24358 6163735 break;
24359
24360 case 1:
24361 3204584 set_register(sarg1, int32_t(zc::math::Cos(rangle) * 10000.0));
24362 3204584 break;
24363
24364 case 2:
24365 76 set_register(sarg1, int32_t(zc::math::Tan(rangle) * 10000.0));
24366 76 break;
24367 }
24368 9368395 }
24369
24370 1263 void do_degtorad()
24371 {
24372 1263 double rangle = (SH::get_arg(sarg2, false) / 10000.0) * (PI / 180.0);
24373 1263 rangle += rangle < 0?-0.00005:0.00005;
24374
24375 1263 set_register(sarg1, int32_t(rangle * 10000.0));
24376 1263 }
24377
24378 59701 void do_radtodeg()
24379 {
24380 59701 double rangle = (SH::get_arg(sarg2, false) / 10000.0) * (180.0 / PI);
24381
24382 59701 set_register(sarg1, int32_t(rangle * 10000.0));
24383 59701 }
24384
24385 14918 void do_asin(const bool v)
24386 {
24387 14918 double temp = double(SH::get_arg(sarg2, v)) / 10000.0;
24388
24389
2/4
✓ Branch 0 taken 14918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14918 times.
✗ Branch 3 not taken.
14918 if(temp >= -1 && temp <= 1)
24390 14918 set_register(sarg1, int32_t(asin(temp) * 10000.0));
24391 else
24392 {
24393 Z_scripterrlog("Script attempted to pass %ld into ArcSin!\n",temp);
24394 set_register(sarg1, -10000);
24395 }
24396 14918 }
24397
24398 void do_acos(const bool v)
24399 {
24400 double temp = double(SH::get_arg(sarg2, v)) / 10000.0;
24401
24402 if(temp >= -1 && temp <= 1)
24403 set_register(sarg1, int32_t(acos(temp) * 10000.0));
24404 else
24405 {
24406 Z_scripterrlog("Script attempted to pass %ld into ArcCos!\n",temp);
24407 set_register(sarg1, -10000);
24408 }
24409 }
24410
24411 863764 void do_arctan()
24412 {
24413 863764 double xpos = ri->d[rINDEX] / 10000.0;
24414 863764 double ypos = ri->d[rINDEX2] / 10000.0;
24415
24416 863764 set_register(sarg1, int32_t(atan2(ypos, xpos) * 10000.0));
24417 863764 }
24418
24419 void do_abs(const bool v)
24420 {
24421 int32_t temp = SH::get_arg(sarg1, v);
24422 set_register(sarg1, abs(temp));
24423 }
24424
24425 27 void do_log10(const bool v)
24426 {
24427 27 double temp = double(SH::get_arg(sarg1, v)) / 10000.0;
24428
24429
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(temp > 0)
24430 27 set_register(sarg1, int32_t(log10(temp) * 10000.0));
24431 else
24432 {
24433 Z_eventlog("Script tried to calculate log of %f\n", temp / 10000.0);
24434 set_register(sarg1, 0);
24435 }
24436 27 }
24437
24438 20 void do_naturallog(const bool v)
24439 {
24440 20 double temp = double(SH::get_arg(sarg1, v)) / 10000.0;
24441
24442
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(temp > 0)
24443 20 set_register(sarg1, int32_t(log(temp) * 10000.0));
24444 // else if(temp == 0)
24445 // {
24446 // Z_eventlog("Script tried to calculate ln of 0\n");
24447 // set_register(sarg1, MIN_SIGNED_32);
24448 // }
24449 else
24450 {
24451 Z_eventlog("Script tried to calculate ln of %f\n", temp / 10000.0);
24452 set_register(sarg1, 0);
24453 }
24454 20 }
24455
24456 void do_min(const bool v)
24457 {
24458 int32_t temp = SH::get_arg(sarg2, v);
24459 int32_t temp2 = get_register(sarg1);
24460 set_register(sarg1, zc_min(temp2, temp));
24461 }
24462
24463 void do_max(const bool v)
24464 {
24465 int32_t temp = SH::get_arg(sarg2, v);
24466 int32_t temp2 = get_register(sarg1);
24467
24468 set_register(sarg1, zc_max(temp2, temp));
24469 }
24470
24471
24472 2703958 void do_rnd(const bool v)
24473 {
24474 2703958 int32_t temp = SH::get_arg(sarg2, v) / 10000;
24475
24476
2/2
✓ Branch 0 taken 2703775 times.
✓ Branch 1 taken 183 times.
2703958 if(temp > 0)
24477 2703775 set_register(sarg1, (zc_oldrand() % temp) * 10000);
24478
1/2
✓ Branch 0 taken 183 times.
✗ Branch 1 not taken.
183 else if(temp < 0)
24479 183 set_register(sarg1, (zc_oldrand() % (-temp)) * -10000);
24480 else
24481 set_register(sarg1, 0); // Just return 0. (Do not log an error)
24482 2703958 }
24483
24484 void do_srnd(const bool v)
24485 {
24486 uint32_t seed = SH::get_arg(sarg1, v); //Do not `/10000`- allow the decimal portion to be used! -V
24487 zc_game_srand(seed);
24488 }
24489
24490 void do_srndrnd()
24491 {
24492 //Randomize the seed to the current system time, + or - the product of 2 random numbers.
24493 int32_t seed = time(0) + ((zc_rand() * int64_t(zc_rand())) * (zc_rand(1) ? 1 : -1));
24494 set_register(sarg1, seed);
24495 zc_game_srand(seed);
24496 }
24497
24498 //Returns the system Real-Time-Clock value for a specific type.
24499 void FFScript::getRTC(const bool v)
24500 {
24501 //int32_t type = get_register(sarg1) / 10000;
24502 //zprint("FFCore.getRTC() type == %d\n",type);
24503 //int32_t time = getTime(type);
24504 //zprint("FFCore.getRTC() time == %d\n",time);
24505 //zprint("FFCore.getRTC() time * 10000 == %d\n",time);
24506 //set_register(sarg1, getTime((byte)(SH::get_arg(sarg2, v) / 10000)) * 10000);
24507 set_register(sarg1, getTime((get_register(sarg1) / 10000)) * 10000);
24508 }
24509
24510
24511 void do_factorial(const bool v)
24512 {
24513 int32_t temp;
24514
24515 if(v)
24516 return; //must factorial a register, not a value (why is this exactly? ~Joe123)
24517 else
24518 {
24519 temp = get_register(sarg1) / 10000;
24520
24521 if(temp < 2)
24522 {
24523 set_register(sarg1, temp >= 0 ? 10000 : 00000);
24524 return;
24525 }
24526 }
24527
24528 int32_t temp2 = 1;
24529
24530 for(int32_t temp3 = temp; temp > 1; temp--)
24531 temp2 *= temp3;
24532
24533 set_register(sarg1, temp2 * 10000);
24534 }
24535
24536 77 void do_power(bool v, const bool inv = false)
24537 {
24538 77 bool v2 = false;
24539
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(inv) zc_swap(v,v2);
24540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 auto destreg = (inv ? sarg2 : sarg1);
24541 77 double temp = double(SH::get_arg(sarg2, v)) / 10000.0;
24542 77 double temp2 = double(SH::get_arg(sarg1, v2)) / 10000.0;
24543
24544
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
77 if(temp == 0 && temp2 == 0)
24545 {
24546 set_register(destreg, 10000);
24547 return;
24548 }
24549
24550 77 set_register(destreg, int32_t(pow(temp2, temp) * 10000.0));
24551 77 }
24552
24553 void do_lpower(bool v, const bool inv = false)
24554 {
24555 bool v2 = false;
24556 if(inv) zc_swap(v,v2);
24557 auto destreg = (inv ? sarg2 : sarg1);
24558 int32_t temp = SH::get_arg(sarg2, v);
24559 int32_t temp2 = SH::get_arg(sarg1, v2);
24560
24561 if(temp == 0 && temp2 == 0)
24562 {
24563 set_register(destreg, 1);
24564 return;
24565 }
24566
24567 set_register(destreg, int32_t(pow(temp2, temp)));
24568 }
24569
24570 //could use recursion or something to avoid truncation.
24571 void do_ipower(const bool v)
24572 {
24573 double sarg2val = double(SH::get_arg(sarg2, v));
24574 if ( sarg2val == 0 )
24575 {
24576 Z_scripterrlog("Division by 0 Err: InvPower() exponent divisor cannot be 0!!\n");
24577 set_register(sarg1, 1);
24578 return;
24579 }
24580 double temp = 10000.0 / sarg2val;
24581 double temp2 = double(get_register(sarg1)) / 10000.0;
24582
24583 if(temp == 0 && temp2 == 0)
24584 {
24585 Z_scripterrlog("Script attempted to calculate 0 to the power 0!\n");
24586 set_register(sarg1, 1);
24587 return;
24588 }
24589
24590 set_register(sarg1, int32_t(pow(temp2, temp) * 10000.0));
24591 }
24592
24593 2539388 void do_sqroot(const bool v)
24594 {
24595 2539388 double temp = double(SH::get_arg(sarg2, v)) / 10000.0;
24596
24597
2/2
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 2538966 times.
2539388 if(temp < 0)
24598 {
24599 422 Z_scripterrlog("Script attempted to calculate square root of %ld!\n", temp);
24600 422 set_register(sarg1, -10000);
24601 422 return;
24602 }
24603
24604 2538966 set_register(sarg1, int32_t(sqrt(temp) * 10000.0));
24605 2539388 }
24606
24607 ///----------------------------------------------------------------------------------------------------//
24608 //Bitwise
24609
24610 void do_and(const bool v)
24611 {
24612 int32_t temp = SH::get_arg(sarg2, v) / 10000;
24613 int32_t temp2 = get_register(sarg1) / 10000;
24614 set_register(sarg1, (temp2 & temp) * 10000);
24615 }
24616
24617 34306 void do_and32(const bool v)
24618 {
24619 34306 int32_t temp = SH::get_arg(sarg2, v);
24620 34306 int32_t temp2 = get_register(sarg1);
24621 34306 set_register(sarg1, (temp2 & temp));
24622 34306 }
24623
24624 5734132 void do_or(const bool v)
24625 {
24626 5734132 int32_t temp = SH::get_arg(sarg2, v) / 10000;
24627 5734132 int32_t temp2 = get_register(sarg1) / 10000;
24628 5734132 set_register(sarg1, (temp2 | temp) * 10000);
24629 5734132 }
24630
24631 17 void do_or32(const bool v)
24632 {
24633 17 int32_t temp = SH::get_arg(sarg2, v);
24634 17 int32_t temp2 = get_register(sarg1);
24635 17 set_register(sarg1, (temp2 | temp));
24636 17 }
24637
24638 191297 void do_xor(const bool v)
24639 {
24640 191297 int32_t temp = SH::get_arg(sarg2, v) / 10000;
24641 191297 int32_t temp2 = get_register(sarg1) / 10000;
24642 191297 set_register(sarg1, (temp2 ^ temp) * 10000);
24643 191297 }
24644
24645 void do_xor32(const bool v)
24646 {
24647 int32_t temp = SH::get_arg(sarg2, v);
24648 int32_t temp2 = get_register(sarg1);
24649 set_register(sarg1, (temp2 ^ temp));
24650 }
24651
24652 void do_nand(const bool v)
24653 {
24654 int32_t temp = SH::get_arg(sarg2, v) / 10000;
24655 int32_t temp2 = get_register(sarg1) / 10000;
24656 set_register(sarg1, (~(temp2 & temp)) * 10000);
24657 }
24658
24659 void do_nor(const bool v)
24660 {
24661 int32_t temp = SH::get_arg(sarg2, v) / 10000;
24662 int32_t temp2 = get_register(sarg1) / 10000;
24663 set_register(sarg1, (~(temp2 | temp)) * 10000);
24664 }
24665
24666 void do_xnor(const bool v)
24667 {
24668 int32_t temp = SH::get_arg(sarg2, v) / 10000;
24669 int32_t temp2 = get_register(sarg1) / 10000;
24670 set_register(sarg1, (~(temp2 ^ temp)) * 10000);
24671 }
24672
24673 void do_not(const bool v)
24674 {
24675 int32_t temp = SH::get_arg(sarg2, v);
24676 set_register(sarg1, !temp);
24677 }
24678
24679 1427960 void do_bitwisenot(const bool v)
24680 {
24681 1427960 int32_t temp = SH::get_arg(sarg1, v) / 10000;
24682 1427960 set_register(sarg1, (~temp) * 10000);
24683 1427960 }
24684
24685 void do_bitwisenot32(const bool v)
24686 {
24687 int32_t temp = SH::get_arg(sarg1, v);
24688 set_register(sarg1, (~temp));
24689 }
24690
24691 62840797 void do_lshift(const bool v)
24692 {
24693 62840797 int32_t temp = SH::get_arg(sarg2, v) / 10000;
24694 62840797 int32_t temp2 = get_register(sarg1) / 10000;
24695 62840797 set_register(sarg1, (temp2 << temp) * 10000);
24696 62840797 }
24697
24698 22 void do_lshift32(const bool v)
24699 {
24700 22 int32_t temp = SH::get_arg(sarg2, v) / 10000;
24701 22 int32_t temp2 = get_register(sarg1);
24702 22 set_register(sarg1, (temp2 << temp));
24703 22 }
24704
24705 20604135 void do_rshift(const bool v)
24706 {
24707 20604135 int32_t temp = SH::get_arg(sarg2, v) / 10000;
24708 20604135 int32_t temp2 = get_register(sarg1) / 10000;
24709 20604135 set_register(sarg1, (temp2 >> temp) * 10000);
24710 20604135 }
24711
24712 34296 void do_rshift32(const bool v)
24713 {
24714 34296 int32_t temp = SH::get_arg(sarg2, v) / 10000;
24715 34296 int32_t temp2 = get_register(sarg1);
24716 34296 set_register(sarg1, (temp2 >> temp));
24717 34296 }
24718
24719 ///----------------------------------------------------------------------------------------------------//
24720 //Casting
24721
24722 void do_boolcast(const bool isFloat)
24723 {
24724 set_register(sarg1, (get_register(sarg1) ? (isFloat ? 1 : 10000) : 0));
24725 }
24726
24727 ///----------------------------------------------------------------------------------------------------//
24728 //Text ptr functions
24729 1259 void do_fontheight()
24730 {
24731 1259 int32_t font = get_register(sarg1)/10000;
24732 1259 ri->d[rEXP1] = text_height(get_zc_font(font))*10000;
24733 1259 }
24734
24735 13724 void do_strwidth()
24736 {
24737 13724 int32_t strptr = get_register(sarg1)/10000;
24738 13724 int32_t font = get_register(sarg2)/10000;
24739 13724 string the_string;
24740
1/2
✓ Branch 0 taken 13724 times.
✗ Branch 1 not taken.
13724 ArrayH::getString(strptr, the_string, 512);
24741
2/4
✓ Branch 0 taken 13724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13724 times.
✗ Branch 3 not taken.
13724 ri->d[rEXP1] = text_length(get_zc_font(font), the_string.c_str())*10000;
24742 13724 }
24743
24744 37547 void do_charwidth()
24745 {
24746 37547 char chr = get_register(sarg1)/10000;
24747 37547 int32_t font = get_register(sarg2)/10000;
24748 37547 char *cstr = new char[2];
24749 37547 cstr[0] = chr;
24750 37547 cstr[1] = '\0';
24751 37547 ri->d[rEXP1] = text_length(get_zc_font(font), cstr)*10000;
24752
1/2
✓ Branch 0 taken 37547 times.
✗ Branch 1 not taken.
37547 delete[] cstr;
24753 37547 }
24754
24755 int32_t do_msgwidth(int32_t msg, char const* str)
24756 {
24757 if(BC::checkMessage(msg, str) != SH::_NoError)
24758 {
24759 return -1;
24760 }
24761
24762 int32_t v = text_length(get_zc_font(MsgStrings[msg].font),
24763 MsgStrings[msg].s.substr(0,MsgStrings[msg].s.find_last_not_of(' ')+1).c_str());
24764 return v;
24765 }
24766
24767 int32_t do_msgheight(int32_t msg, char const* str)
24768 {
24769 if(BC::checkMessage(msg, str) != SH::_NoError)
24770 {
24771 return -1;
24772 }
24773 return text_height(get_zc_font(MsgStrings[msg].font));
24774 }
24775
24776 ///----------------------------------------------------------------------------------------------------//
24777 //Gameplay functions
24778
24779 79 void do_warp(bool v)
24780 {
24781 79 int32_t dmapid = SH::get_arg(sarg1, v) / 10000;
24782 79 int32_t screenid = SH::get_arg(sarg2, v) / 10000;
24783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if ( ((unsigned)dmapid) >= MAXDMAPS )
24784 {
24785 Z_scripterrlog("Invalid DMap ID (%d) passed to Warp(). Aborting.\n", dmapid);
24786 return;
24787 }
24788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if ( ((unsigned)screenid) >= MAPSCRS )
24789 {
24790 Z_scripterrlog("Invalid Screen ID (%d) passed to Warp(). Aborting.\n", screenid);
24791 return;
24792 }
24793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if ( DMaps[dmapid].map*MAPSCRS+DMaps[dmapid].xoff+screenid >= (int32_t)TheMaps.size() )
24794 {
24795 Z_scripterrlog("Invalid destination passed to Warp(). Aborting.\n");
24796 return;
24797 }
24798 79 tmpscr->sidewarpdmap[0] = dmapid;
24799 79 tmpscr->sidewarpscr[0] = screenid;
24800 79 tmpscr->sidewarptype[0] = wtIWARP;
24801 79 Hero.ffwarp = true;
24802 79 }
24803
24804 126 void do_pitwarp(bool v)
24805 {
24806 126 int32_t dmapid = SH::get_arg(sarg1, v) / 10000;
24807 126 int32_t screenid = SH::get_arg(sarg2, v) / 10000;
24808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if ( ((unsigned)dmapid) >= MAXDMAPS )
24809 {
24810 Z_scripterrlog("Invalid DMap ID (%d) passed to PitWarp(). Aborting.\n", dmapid);
24811 return;
24812 }
24813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if ( ((unsigned)screenid) >= MAPSCRS )
24814 {
24815 Z_scripterrlog("Invalid Screen ID (%d) passed to PitWarp(). Aborting.\n", screenid);
24816 return;
24817 }
24818 //Extra sanity guard.
24819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if ( DMaps[dmapid].map*MAPSCRS+DMaps[dmapid].xoff+screenid >= (int32_t)TheMaps.size() )
24820 {
24821 Z_scripterrlog("Invalid destination passed to Warp(). Aborting.\n");
24822 return;
24823 }
24824 126 tmpscr->sidewarpdmap[0] = dmapid;
24825 126 tmpscr->sidewarpscr[0] = screenid;
24826 126 tmpscr->sidewarptype[0] = wtIWARP;
24827 126 Hero.ffwarp = true;
24828 126 Hero.ffpit = true;
24829 126 }
24830
24831 void do_breakshield()
24832 {
24833 int32_t UID = get_register(sarg1);
24834
24835 for(int32_t j = 0; j < guys.Count(); j++)
24836 if(guys.spr(j)->getUID() == UID)
24837 {
24838 ((enemy*)guys.spr(j))->break_shield();
24839 return;
24840 }
24841 }
24842
24843 void do_showsavescreen()
24844 {
24845 bool didsaved = save_game(false, 0);
24846 set_register(sarg1, didsaved ? 10000 : 0);
24847 }
24848
24849 10848 void do_selectweapon(bool v, int32_t btn)
24850 {
24851
2/4
✓ Branch 0 taken 5268 times.
✓ Branch 1 taken 5580 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10848 switch(btn)
24852 {
24853 case 1:
24854
1/2
✓ Branch 0 taken 5580 times.
✗ Branch 1 not taken.
5580 if(!get_qr(qr_SELECTAWPN))
24855 return;
24856 5580 break;
24857 case 2:
24858 if(!get_qr(qr_SET_XBUTTON_ITEMS))
24859 return;
24860 break;
24861 case 3:
24862 if(!get_qr(qr_SET_YBUTTON_ITEMS))
24863 return;
24864 break;
24865 }
24866
24867 10848 byte dir=(byte)(SH::get_arg(sarg1, v)/10000);
24868
24869 // Selection directions don't match the normal ones...
24870
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
✓ Branch 4 taken 10831 times.
10848 switch(dir)
24871 {
24872 case 0:
24873 dir=SEL_UP;
24874 break;
24875
24876 case 1:
24877 dir=SEL_DOWN;
24878 break;
24879
24880 case 2:
24881 17 dir=SEL_LEFT;
24882 17 break;
24883
24884 case 3:
24885 10831 dir=SEL_RIGHT;
24886 10831 break;
24887
24888 default:
24889 return;
24890 }
24891
24892
2/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5268 times.
✓ Branch 2 taken 5580 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
10848 switch(btn)
24893 {
24894 case 0:
24895 5268 selectNextBWpn(dir);
24896 5268 break;
24897 case 1:
24898 5580 selectNextAWpn(dir);
24899 5580 break;
24900 case 2:
24901 selectNextXWpn(dir);
24902 break;
24903 case 3:
24904 selectNextYWpn(dir);
24905 break;
24906 }
24907 10848 }
24908
24909 ///----------------------------------------------------------------------------------------------------//
24910 //Screen Information
24911
24912 16274661 void do_issolid()
24913 {
24914 16274661 int32_t x = int32_t(ri->d[rINDEX] / 10000);
24915 16274661 int32_t y = int32_t(ri->d[rINDEX2] / 10000);
24916
24917 16274661 set_register(sarg1, (_walkflag(x, y, 1) ? 10000 : 0));
24918 16274661 }
24919
24920 void do_mapdataissolid()
24921 {
24922 if ( ri->mapsref == MAX_SIGNED_32 )
24923 {
24924 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","isSolid()");
24925 set_register(sarg1,10000);
24926 }
24927 else
24928 {
24929 //mapscr *m = GetMapscr(ri->mapsref);
24930 int32_t x = int32_t(ri->d[rINDEX] / 10000);
24931 int32_t y = int32_t(ri->d[rINDEX2] / 10000);
24932 switch(ri->mapsref)
24933 {
24934 case MAPSCR_TEMP0:
24935 set_register(sarg1, (_walkflag(x, y, 1)) ? 10000 : 0);
24936 break;
24937 case MAPSCR_SCROLL0:
24938 set_register(sarg1, (_walkflag(x, y, 1, FFCore.ScrollingScreens[0], FFCore.ScrollingScreens[1], FFCore.ScrollingScreens[2])) ? 10000 : 0);
24939 break;
24940 default:
24941 set_register(sarg1, (_walkflag(x, y, 1, GetMapscr(ri->mapsref)) ? 10000 : 0));
24942 }
24943 }
24944 }
24945
24946 void do_mapdataissolid_layer()
24947 {
24948 if ( ri->mapsref == MAX_SIGNED_32 )
24949 {
24950 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","isSolidLayer()");
24951 set_register(sarg1,10000);
24952 }
24953 else
24954 {
24955 //mapscr *m = GetMapscr(ri->mapsref);
24956 int32_t x = int32_t(ri->d[rINDEX] / 10000);
24957 int32_t y = int32_t(ri->d[rINDEX2] / 10000);
24958 int32_t layer = int32_t(ri->d[rEXP1] / 10000);
24959 if(BC::checkBounds(layer, 0, 6, "mapdata->isSolidLayer()") != SH::_NoError)
24960 {
24961 set_register(sarg1,10000);
24962 }
24963 else
24964 {
24965 switch(ri->mapsref)
24966 {
24967 case MAPSCR_TEMP0:
24968 set_register(sarg1, (_walkflag_layer(x, y, 1, FFCore.tempScreens[layer])) ? 10000 : 0);
24969 break;
24970 case MAPSCR_SCROLL0:
24971 set_register(sarg1, (_walkflag_layer(x, y, 1, FFCore.ScrollingScreens[layer])) ? 10000 : 0);
24972 break;
24973 default:
24974 mapscr* m = GetMapscr(ri->mapsref);
24975 if(layer > 0)
24976 {
24977 if(m->layermap[layer] == 0)
24978 {
24979 set_register(sarg1,10000);
24980 break;
24981 }
24982 m = &TheMaps[(m->layermap[layer]*MAPSCRS + m->layerscreen[layer])];
24983 }
24984 set_register(sarg1, (_walkflag_layer(x, y, 1, m) ? 10000 : 0));
24985 break;
24986 }
24987 }
24988 }
24989 }
24990
24991 void do_issolid_layer()
24992 {
24993 int32_t x = int32_t(ri->d[rINDEX] / 10000);
24994 int32_t y = int32_t(ri->d[rINDEX2] / 10000);
24995 int32_t layer = int32_t(ri->d[rEXP1] / 10000);
24996 if(BC::checkBounds(layer, 0, 6, "Screen->isSolidLayer()") != SH::_NoError)
24997 {
24998 set_register(sarg1,10000);
24999 }
25000 else
25001 {
25002 set_register(sarg1, (_walkflag_layer(x, y, 1, FFCore.tempScreens[layer])) ? 10000 : 0);
25003 }
25004 }
25005
25006 249 void do_setsidewarp()
25007 {
25008 249 int32_t warp = SH::read_stack(ri->sp + 3) / 10000;
25009 249 int32_t scrn = SH::read_stack(ri->sp + 2) / 10000;
25010 249 int32_t dmap = SH::read_stack(ri->sp + 1) / 10000;
25011 249 int32_t type = SH::read_stack(ri->sp + 0) / 10000;
25012
25013
2/4
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
498 if(BC::checkBounds(warp, -1, 3, "Screen->SetSideWarp") != SH::_NoError ||
25014
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 BC::checkBounds(scrn, -1, 0x87, "Screen->SetSideWarp") != SH::_NoError ||
25015
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 BC::checkBounds(dmap, -1, MAXDMAPS - 1, "Screen->SetSideWarp") != SH::_NoError ||
25016 249 BC::checkBounds(type, -1, wtMAX - 1, "Screen->SetSideWarp") != SH::_NoError)
25017 return;
25018
25019
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(scrn > -1)
25020 249 tmpscr->sidewarpscr[warp] = scrn;
25021
25022
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(dmap > -1)
25023 249 tmpscr->sidewarpdmap[warp] = dmap;
25024
25025
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(type > -1)
25026 249 tmpscr->sidewarptype[warp] = type;
25027 249 }
25028
25029 5 void do_settilewarp()
25030 {
25031 5 int32_t warp = SH::read_stack(ri->sp + 3) / 10000;
25032 5 int32_t scrn = SH::read_stack(ri->sp + 2) / 10000;
25033 5 int32_t dmap = SH::read_stack(ri->sp + 1) / 10000;
25034 5 int32_t type = SH::read_stack(ri->sp + 0) / 10000;
25035
25036
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
10 if(BC::checkBounds(warp, -1, 3, "Screen->SetTileWarp") != SH::_NoError ||
25037
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 BC::checkBounds(scrn, -1, 0x87, "Screen->SetTileWarp") != SH::_NoError ||
25038
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 BC::checkBounds(dmap, -1, MAXDMAPS - 1, "Screen->SetTileWarp") != SH::_NoError ||
25039 5 BC::checkBounds(type, -1, wtMAX - 1, "Screen->SetTileWarp") != SH::_NoError)
25040 return;
25041
25042
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(scrn > -1)
25043 5 tmpscr->tilewarpscr[warp] = scrn;
25044
25045
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(dmap > -1)
25046 5 tmpscr->tilewarpdmap[warp] = dmap;
25047
25048
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(type > -1)
25049 5 tmpscr->tilewarptype[warp] = type;
25050 5 }
25051
25052 354940 void do_getsidewarpdmap(const bool v)
25053 {
25054 354940 int32_t warp = SH::get_arg(sarg1, v) / 10000;
25055
25056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354940 times.
354940 if(BC::checkBounds(warp, -1, 3, "Screen->GetSideWarpDMap") != SH::_NoError)
25057 {
25058 set_register(sarg1, -10000);
25059 return;
25060 }
25061
25062 354940 set_register(sarg1, tmpscr->sidewarpdmap[warp]*10000);
25063 354940 }
25064
25065 void do_getsidewarpscr(const bool v)
25066 {
25067 int32_t warp = SH::get_arg(sarg1, v) / 10000;
25068
25069 if(BC::checkBounds(warp, -1, 3, "Screen->GetSideWarpScreen") != SH::_NoError)
25070 {
25071 set_register(sarg1, -10000);
25072 return;
25073 }
25074
25075 set_register(sarg1, tmpscr->sidewarpscr[warp]*10000);
25076 }
25077
25078 void do_getsidewarptype(const bool v)
25079 {
25080 int32_t warp = SH::get_arg(sarg1, v) / 10000;
25081
25082 if(BC::checkBounds(warp, -1, 3, "Screen->GetSideWarpType") != SH::_NoError)
25083 {
25084 set_register(sarg1, -10000);
25085 return;
25086 }
25087
25088 set_register(sarg1, tmpscr->sidewarptype[warp]*10000);
25089 }
25090
25091 354943 void do_gettilewarpdmap(const bool v)
25092 {
25093 354943 int32_t warp = SH::get_arg(sarg1, v) / 10000;
25094
25095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354943 times.
354943 if(BC::checkBounds(warp, -1, 3, "Screen->GetTileWarpDMap") != SH::_NoError)
25096 {
25097 set_register(sarg1, -10000);
25098 return;
25099 }
25100
25101 354943 set_register(sarg1, tmpscr->tilewarpdmap[warp]*10000);
25102 354943 }
25103
25104 3 void do_gettilewarpscr(const bool v)
25105 {
25106 3 int32_t warp = SH::get_arg(sarg1, v) / 10000;
25107
25108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(BC::checkBounds(warp, -1, 3, "Screen->GetTileWarpScreen") != SH::_NoError)
25109 {
25110 set_register(sarg1, -10000);
25111 return;
25112 }
25113
25114 3 set_register(sarg1, tmpscr->tilewarpscr[warp]*10000);
25115 3 }
25116
25117 3 void do_gettilewarptype(const bool v)
25118 {
25119 3 int32_t warp = SH::get_arg(sarg1, v) / 10000;
25120
25121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(BC::checkBounds(warp, -1, 3, "Screen->GetTileWarpType") != SH::_NoError)
25122 {
25123 set_register(sarg1, -10000);
25124 return;
25125 }
25126
25127 3 set_register(sarg1, tmpscr->tilewarptype[warp]*10000);
25128 3 }
25129
25130 12696160 void do_layerscreen()
25131 {
25132 12696160 int32_t layer = (get_register(sarg2) / 10000) - 1;
25133
25134
3/4
✓ Branch 0 taken 12696160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10821826 times.
✓ Branch 3 taken 1874334 times.
12696160 if(BC::checkBounds(layer, 0, 5, "Screen->LayerScreen") != SH::_NoError ||
25135 12696160 tmpscr->layermap[layer] == 0)
25136 1874334 set_register(sarg1, -10000);
25137 else
25138 10821826 set_register(sarg1, tmpscr->layerscreen[layer] * 10000);
25139 12696160 }
25140
25141 16038753 void do_layermap()
25142 {
25143 16038753 int32_t layer = (get_register(sarg2) / 10000) - 1;
25144
25145
3/4
✓ Branch 0 taken 16038753 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13868561 times.
✓ Branch 3 taken 2170192 times.
16038753 if(BC::checkBounds(layer, 0, 5, "Screen->LayerMap") != SH::_NoError ||
25146 16038753 tmpscr->layermap[layer] == 0)
25147 2170192 set_register(sarg1, -10000);
25148 else
25149 13868561 set_register(sarg1, tmpscr->layermap[layer] * 10000);
25150 16038753 }
25151
25152
25153
25154
25155 60 void do_triggersecrets()
25156 {
25157 60 hidden_entrance(0, true, false, -4);
25158 //hidden_entrance(0,true,single16,scombo);
25159 //bool findentrance(int32_t x, int32_t y, int32_t flag, bool setflag)
25160 //We need a variation on these that triggers any combos with a given flag. -Z
25161 60 }
25162
25163
25164
25165
25166 void do_getscreenflags()
25167 {
25168 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25169 int32_t scrn = ri->d[rINDEX2] / 10000;
25170 int32_t flagset = ri->d[rINDEX] / 10000;
25171
25172 if(BC::checkMapID(map, "Game->GetScreenFlags") != SH::_NoError ||
25173 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenFlags") != SH::_NoError ||
25174 BC::checkBounds(flagset, 0, 9, "Game->GetScreenFlags") != SH::_NoError)
25175 return;
25176
25177 set_register(sarg1, get_screenflags(&TheMaps[map * MAPSCRS + scrn], flagset));
25178 }
25179
25180 void do_getscreeneflags()
25181 {
25182 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25183 int32_t scrn = ri->d[rINDEX2] / 10000;
25184 int32_t flagset = ri->d[rINDEX] / 10000;
25185
25186 if(BC::checkMapID(map, "Game->GetScreenEFlags") != SH::_NoError ||
25187 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenEFlags") != SH::_NoError ||
25188 BC::checkBounds(flagset, 0, 9, "Game->GetScreenEFlags") != SH::_NoError)
25189 return;
25190
25191 set_register(sarg1, get_screeneflags(&TheMaps[map * MAPSCRS + scrn], flagset));
25192 }
25193
25194 void FFScript::do_graphics_getpixel()
25195 {
25196 int32_t yoffset = 0;
25197 const bool brokenOffset= ( (get_er(er_BITMAPOFFSET)!=0) || (get_qr(qr_BITMAPOFFSETFIX)!=0) );
25198 int32_t ref = (ri->d[rEXP1]);
25199
25200 if ( ref == -10000 || ref == -20000 || ref >= 10000 ) //Bitmaps Loaded by LoadBitmapID have values of -10000 to 70000
25201 {
25202 ref /= 10000;
25203 }
25204 else ref -= 10; //Bitmaps other than those loaded by LoadBitmapID
25205
25206 BITMAP *bitty = FFCore.GetScriptBitmap(ref);
25207 int32_t xpos = ri->d[rINDEX2] / 10000;
25208
25209 if(!brokenOffset && ref == -1 )
25210 {
25211 yoffset = 56; //should this be -56?
25212 }
25213 else
25214 {
25215 yoffset = 0;
25216 }
25217
25218 int32_t ypos = (ri->d[rINDEX] / 10000)+yoffset;
25219 if(!bitty)
25220 {
25221 bitty = scrollbuf;
25222 }
25223
25224 int32_t ret = getpixel(bitty, xpos, ypos); //This is a palette index value.
25225
25226 if(!get_qr(qr_BROKEN_GETPIXEL_VALUE))
25227 ret *= 10000;
25228 set_register(sarg1, ret);
25229 }
25230
25231 //Some of these need to be reduced to two inputs. -Z
25232
25233 int32_t get_screendoor(mapscr *m, int32_t d)
25234 {
25235 int32_t f = m->door[d];
25236 return f*10000;
25237 }
25238
25239
25240
25241 int32_t get_screenlayeropacity(mapscr *m, int32_t d)
25242 {
25243 int32_t f = m->layeropacity[d]; //6 of these
25244 return f*10000;
25245 }
25246
25247 int32_t get_screensecretcombo(mapscr *m, int32_t d)
25248 {
25249 int32_t f = m->secretcombo[d]; //128 of these
25250 return f*10000;
25251 }
25252
25253 int32_t get_screensecretcset(mapscr *m, int32_t d)
25254 {
25255 int32_t f = m->secretcset[d]; //128 of these
25256 return f*10000;
25257 }
25258
25259 int32_t get_screensecretflag(mapscr *m, int32_t d)
25260 {
25261 int32_t f = m->secretflag[d]; //128 of these
25262 return f*10000;
25263 }
25264
25265 int32_t get_screenlayermap(mapscr *m, int32_t d)
25266 {
25267 int32_t f = m->layermap[d]; //6 of these
25268 return f*10000;
25269 }
25270
25271 int32_t get_screenlayerscreen(mapscr *m, int32_t d)
25272 {
25273 int32_t f = m->layerscreen[d]; //6 of these
25274 return f*10000;
25275 }
25276
25277 int32_t get_screenpath(mapscr *m, int32_t d)
25278 {
25279 int32_t f = m->path[d]; //4 of these
25280 return f*10000;
25281 }
25282
25283 int32_t get_screenwarpReturnX(mapscr *m, int32_t d)
25284 {
25285 int32_t f = m->warpreturnx[d]; //4 of these
25286 return f*10000;
25287 }
25288
25289 int32_t get_screenwarpReturnY(mapscr *m, int32_t d)
25290 {
25291 int32_t f = m->warpreturny[d]; //4 of these
25292 return f*10000;
25293 }
25294 //One too many inputs here. -Z
25295 int32_t get_screenGuy(mapscr *m)
25296 {
25297 int32_t f = m->guy;
25298 return f*10000;
25299 }
25300 //One too many inputs here. -Z
25301 int32_t get_screenString(mapscr *m)
25302 {
25303 int32_t f = m->str;
25304 return f*10000;
25305 }
25306 //One too many inputs here. -Z
25307 int32_t get_screenRoomtype(mapscr *m)
25308 {
25309 int32_t f = m->room;
25310 return f*10000;
25311 }
25312 //One too many inputs here. -Z
25313 int32_t get_screenEntryX(mapscr *m)
25314 {
25315 int32_t f = m->entry_x;
25316 return f*10000;
25317 }
25318 //One too many inputs here. -Z
25319 int32_t get_screenEntryY(mapscr *m)
25320 {
25321 int32_t f = m->entry_y;
25322 return f*10000;
25323 }
25324 //One too many inputs here. -Z
25325 int32_t get_screenitem(mapscr *m)
25326 {
25327 int32_t f = m->item;
25328 return f*10000;
25329 }
25330 //One too many inputs here. -Z
25331 int32_t get_screenundercombo(mapscr *m)
25332 {
25333 int32_t f = m->undercombo;
25334 return f*10000;
25335 }
25336 //One too many inputs here. -Z
25337 int32_t get_screenundercset(mapscr *m)
25338 {
25339 int32_t f = m->undercset;
25340 return f*10000;
25341 }
25342 //One too many inputs here. -Z
25343 int32_t get_screenatchall(mapscr *m)
25344 {
25345 int32_t f = m->catchall;
25346 return f*10000;
25347 }
25348 void do_getscreenLayerOpacity()
25349 {
25350 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25351 int32_t scrn = ri->d[rINDEX2] / 10000;
25352 int32_t d = ri->d[rINDEX] / 10000;
25353
25354 if(BC::checkMapID(map, "Game->GetLayerOpacity(...map...)") != SH::_NoError ||
25355 BC::checkBounds(scrn, 0, 0x87, "Game->GetLayerOpacity(...screen...)") != SH::_NoError ||
25356 BC::checkBounds(d, 0, 6, "Game->GetLayerOpacity(...val...)") != SH::_NoError)
25357 return;
25358
25359 set_register(sarg1, get_screenlayeropacity(&TheMaps[map * MAPSCRS + scrn], d));
25360 }
25361 void do_getscreenSecretCombo()
25362 {
25363 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25364 int32_t scrn = ri->d[rINDEX2] / 10000;
25365 int32_t d = ri->d[rINDEX] / 10000;
25366
25367 if(BC::checkMapID(map, "Game->GetSecretCombo(...map...)") != SH::_NoError ||
25368 BC::checkBounds(scrn, 0, 0x87, "Game->GetSecretCombo(...screen...)") != SH::_NoError ||
25369 BC::checkBounds(d, 0, 127, "Game->GetSecretCombo(...val...)") != SH::_NoError)
25370 return;
25371
25372 set_register(sarg1, get_screensecretcombo(&TheMaps[map * MAPSCRS + scrn], d));
25373 }
25374
25375 void do_getscreenSecretCSet()
25376 {
25377 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25378 int32_t scrn = ri->d[rINDEX2] / 10000;
25379 int32_t d = ri->d[rINDEX] / 10000;
25380
25381 if(BC::checkMapID(map, "Game->GetSecretCSet(...map...)") != SH::_NoError ||
25382 BC::checkBounds(scrn, 0, 0x87, "Game->GetSecretCSet(...screen...)") != SH::_NoError ||
25383 BC::checkBounds(d, 0, 127, "Game->GetSecretCSet(...val...)") != SH::_NoError)
25384 return;
25385
25386 set_register(sarg1, get_screensecretcset(&TheMaps[map * MAPSCRS + scrn], d));
25387 }
25388
25389 void do_getscreenSecretFlag()
25390 {
25391 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25392 int32_t scrn = ri->d[rINDEX2] / 10000;
25393 int32_t d = ri->d[rINDEX] / 10000;
25394
25395 if(BC::checkMapID(map, "Game->GetSecretFlag(...map...)") != SH::_NoError ||
25396 BC::checkBounds(scrn, 0, 0x87, "Game->GetSecretFlag(...screen...)") != SH::_NoError ||
25397 BC::checkBounds(d, 0,127, "Game->GetSecretFlag(...val...)") != SH::_NoError)
25398 return;
25399
25400 set_register(sarg1, get_screensecretflag(&TheMaps[map * MAPSCRS + scrn], d));
25401 }
25402 void do_getscreenLayerMap()
25403 {
25404 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25405 int32_t scrn = ri->d[rINDEX2] / 10000;
25406 int32_t d = ri->d[rINDEX] / 10000;
25407
25408 if(BC::checkMapID(map, "Game->GetSreenLayerMap(...map...)") != SH::_NoError ||
25409 BC::checkBounds(scrn, 0, 0x87, "Game->GetSreenLayerMap(...screen...)") != SH::_NoError ||
25410 BC::checkBounds(d, 0, 6, "Game->GetSreenLayerMap(...val...)") != SH::_NoError)
25411 return;
25412
25413 set_register(sarg1, get_screenlayermap(&TheMaps[map * MAPSCRS + scrn], d));
25414 }
25415 void do_getscreenLayerscreen()
25416 {
25417 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25418 int32_t scrn = ri->d[rINDEX2] / 10000;
25419 int32_t d = ri->d[rINDEX] / 10000;
25420
25421 if(BC::checkMapID(map, "Game->GetSreenLayerScreen(...map...)") != SH::_NoError ||
25422 BC::checkBounds(scrn, 0, 0x87, "Game->GetSreenLayerScreen(...screen...)") != SH::_NoError ||
25423 BC::checkBounds(d, 0, 6, "Game->GetSreenLayerScreen(...val...)") != SH::_NoError)
25424 return;
25425
25426 set_register(sarg1, get_screenlayerscreen(&TheMaps[map * MAPSCRS + scrn], d));
25427 }
25428 void do_getscreenPath()
25429 {
25430 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25431 int32_t scrn = ri->d[rINDEX2] / 10000;
25432 int32_t d = ri->d[rINDEX] / 10000;
25433
25434 if(BC::checkMapID(map, "Game->GetSreenPath(...map...)") != SH::_NoError ||
25435 BC::checkBounds(scrn, 0, 0x87, "Game->GetSreenPath(...screen...)") != SH::_NoError ||
25436 BC::checkBounds(d, 0, 3, "Game->GetSreenPath(...val...)") != SH::_NoError)
25437 return;
25438
25439 set_register(sarg1, get_screenpath(&TheMaps[map * MAPSCRS + scrn], d));
25440 }
25441 void do_getscreenWarpReturnX()
25442 {
25443 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25444 int32_t scrn = ri->d[rINDEX2] / 10000;
25445 int32_t d = ri->d[rINDEX] / 10000;
25446
25447 if(BC::checkMapID(map, "Game->GetScreenWarpReturnX(...map...)") != SH::_NoError ||
25448 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenWarpReturnX(...screen...)") != SH::_NoError ||
25449 BC::checkBounds(d, 0, 3, "Game->GetScreenWarpReturnX(...val...)") != SH::_NoError)
25450 return;
25451
25452 set_register(sarg1, get_screenwarpReturnX(&TheMaps[map * MAPSCRS + scrn], d));
25453 }
25454 void do_getscreenWarpReturnY()
25455 {
25456 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25457 int32_t scrn = ri->d[rINDEX2] / 10000;
25458 int32_t d = ri->d[rINDEX] / 10000;
25459
25460 if(BC::checkMapID(map, "Game->GetScreenWarpReturnY(...map...)") != SH::_NoError ||
25461 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenWarpReturnY(...screen...)") != SH::_NoError ||
25462 BC::checkBounds(d, 0, 3, "Game->GetScreenWarpReturnY(...val...)") != SH::_NoError)
25463 return;
25464
25465 set_register(sarg1, get_screenwarpReturnY(&TheMaps[map * MAPSCRS + scrn], d));
25466 }
25467
25468 /*
25469 //One too many inputs here. -Z
25470 void do_getscreenatchall()
25471 {
25472 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25473 int32_t scrn = ri->d[rINDEX2] / 10000;
25474 int32_t d = ri->d[rINDEX] / 10000;
25475
25476 if(BC::checkMapID(map, "Game->GetScreenCatchall(...map...)") != SH::_NoError ||
25477 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenCatchall(...screen...)") != SH::_NoError ||
25478 BC::checkBounds(d, 0, 6, "Game->GetScreenCatchall(...val...)") != SH::_NoError)
25479 return;
25480
25481 set_register(sarg1, get_screenatchall(&TheMaps[map * MAPSCRS + scrn], d));
25482 }
25483
25484
25485 //One too many inputs here. -Z
25486 void do_getscreenUndercombo()
25487 {
25488 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25489 int32_t scrn = ri->d[rINDEX2] / 10000;
25490 int32_t d = ri->d[rINDEX] / 10000;
25491
25492 if(BC::checkMapID(map, "Game->GetcreenUndercombo(...map...)") != SH::_NoError ||
25493 BC::checkBounds(scrn, 0, 0x87, "Game->GetcreenUndercombo(...screen...)") != SH::_NoError ||
25494 BC::checkBounds(d, 0, 6, "Game->GetcreenUndercombo(...val...)") != SH::_NoError)
25495 return;
25496
25497 set_register(sarg1, get_screenundercombo(&TheMaps[map * MAPSCRS + scrn], d));
25498 }
25499 //One too many inputs here. -Z
25500 void do_getscreenUnderCSet()
25501 {
25502 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25503 int32_t scrn = ri->d[rINDEX2] / 10000;
25504 int32_t d = ri->d[rINDEX] / 10000;
25505
25506 if(BC::checkMapID(map, "Game->GeScreenUnderCSet(...map...)") != SH::_NoError ||
25507 BC::checkBounds(scrn, 0, 0x87, "Game->GeScreenUnderCSet(...screen...)") != SH::_NoError ||
25508 BC::checkBounds(d, 0, 6, "Game->GeScreenUnderCSet(...val...)") != SH::_NoError)
25509 return;
25510
25511 set_register(sarg1, get_screenundercset(&TheMaps[map * MAPSCRS + scrn], d));
25512 }
25513
25514 //One too many inputs here. -Z
25515 void do_getscreenGuy()
25516 {
25517 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25518 int32_t scrn = ri->d[rINDEX2] / 10000;
25519 int32_t d = ri->d[rINDEX] / 10000;
25520
25521 if(BC::checkMapID(map, "Game->GetScreenGuy(...map...)") != SH::_NoError ||
25522 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenGuy(...screen...)") != SH::_NoError ||
25523 BC::checkBounds(d, 0, 214747, "Game->GetScreenGuy(...val...)") != SH::_NoError)
25524 return;
25525
25526 set_register(sarg1, get_screenGuy(&TheMaps[map * MAPSCRS + scrn], d));
25527 }
25528 //One too many inputs here. -Z
25529 void do_getscreenString()
25530 {
25531 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25532 int32_t scrn = ri->d[rINDEX2] / 10000;
25533 int32_t d = ri->d[rINDEX] / 10000;
25534
25535 if(BC::checkMapID(map, "Game->GetScreenString(...map...)") != SH::_NoError ||
25536 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenString(...screen...)") != SH::_NoError ||
25537 BC::checkBounds(d, 0, 214747, "Game->GetScreenString(...val...)") != SH::_NoError)
25538 return;
25539
25540 set_register(sarg1, get_screenString(&TheMaps[map * MAPSCRS + scrn], d));
25541 }
25542 //One too many inputs here. -Z
25543 void do_getscreenRoomType()
25544 {
25545 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25546 int32_t scrn = ri->d[rINDEX2] / 10000;
25547 int32_t d = ri->d[rINDEX] / 10000;
25548
25549 if(BC::checkMapID(map, "Game->GetScreenRoomType(...map...)") != SH::_NoError ||
25550 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenRoomType(...screen...)") != SH::_NoError ||
25551 BC::checkBounds(d, 0, 214747, "Game->GetScreenRoomType(...val...)") != SH::_NoError)
25552 return;
25553
25554 set_register(sarg1, get_screenRoomtype(&TheMaps[map * MAPSCRS + scrn], d));
25555 }
25556 //One too many inputs here. -Z
25557 void do_getscreenEntryX()
25558 {
25559 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25560 int32_t scrn = ri->d[rINDEX2] / 10000;
25561 int32_t d = ri->d[rINDEX] / 10000;
25562
25563 if(BC::checkMapID(map, "Game->GetScreenEntryX(...map...)") != SH::_NoError ||
25564 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenEntryX(...screen...)") != SH::_NoError ||
25565 BC::checkBounds(d, 0, 214747, "Game->GetScreenEntryX(...val...)") != SH::_NoError)
25566 return;
25567
25568 set_register(sarg1, get_screenEntryX(&TheMaps[map * MAPSCRS + scrn], d));
25569 }
25570 //One too many inputs here. -Z
25571 void do_getscreenEntryY()
25572 {
25573 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25574 int32_t scrn = ri->d[rINDEX2] / 10000;
25575 int32_t d = ri->d[rINDEX] / 10000;
25576
25577 if(BC::checkMapID(map, "Game->GetScreenEntryY(...map...)") != SH::_NoError ||
25578 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenEntryY(...screen...)") != SH::_NoError ||
25579 BC::checkBounds(d, 0, 214747, "Game->GetScreenEntryY(...val...)") != SH::_NoError)
25580 return;
25581
25582 set_register(sarg1, get_screenEntryY(&TheMaps[map * MAPSCRS + scrn], d));
25583 }
25584 //One too many inputs here. -Z
25585 void do_getscreenItem()
25586 {
25587 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25588 int32_t scrn = ri->d[rINDEX2] / 10000;
25589 int32_t d = ri->d[rINDEX] / 10000;
25590
25591 if(BC::checkMapID(map, "Game->GetScreenItem(...map...)") != SH::_NoError ||
25592 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenItem(...screen...)") != SH::_NoError ||
25593 BC::checkBounds(d, 0, 255, "Game->GetScreenItem(...val...)") != SH::_NoError)
25594 return;
25595
25596 set_register(sarg1, get_screenitem(&TheMaps[map * MAPSCRS + scrn], d));
25597 }
25598 */
25599 void do_getscreendoor()
25600 {
25601 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25602 int32_t scrn = ri->d[rINDEX2] / 10000;
25603 int32_t door = ri->d[rINDEX] / 10000;
25604
25605 if(BC::checkMapID(map, "Game->GetScreenDoor(...map...)") != SH::_NoError ||
25606 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenDoor(...screen...)") != SH::_NoError ||
25607 BC::checkBounds(door, 0, 3, "Game->GetScreenDoor(...doorindex...)") != SH::_NoError)
25608 return;
25609
25610 set_register(sarg1, get_screendoor(&TheMaps[map * MAPSCRS + scrn], door));
25611 }
25612
25613 int32_t get_screennpc(mapscr *m, int32_t index)
25614 {
25615 int32_t f = m->enemy[index];
25616 return f*10000;
25617 }
25618
25619
25620 void do_getscreennpc()
25621 {
25622 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25623 int32_t scrn = ri->d[rINDEX2] / 10000;
25624 int32_t enemy = ri->d[rINDEX] / 10000;
25625
25626 if(BC::checkMapID(map, "Game->GetScreenEnemy(...map...)") != SH::_NoError ||
25627 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenEnemy(...screen...)") != SH::_NoError ||
25628 BC::checkBounds(enemy, 0, 9, "Game->GetScreenEnemy(...enemy...)") != SH::_NoError)
25629 return;
25630
25631 set_register(sarg1, get_screennpc(&TheMaps[map * MAPSCRS + scrn], enemy));
25632 }
25633
25634
25635 ///----------------------------------------------------------------------------------------------------//
25636 //Pointer handling
25637
25638 565 void do_isvalidarray()
25639 {
25640 565 int32_t ptr = get_register(sarg1)/10000;
25641
25642 565 set_register(sarg1,0);
25643
25644
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!ptr) return;
25645
25646
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(ptr < 0) //An object array?
25647 {
25648 int32_t objptr = -ptr;
25649 auto it = objectRAM.find(objptr);
25650 if(it == objectRAM.end())
25651 return;
25652 set_register(sarg1,10000);
25653 }
25654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 else if(ptr >= NUM_ZSCRIPT_ARRAYS) //check global
25655 {
25656 dword gptr = ptr - NUM_ZSCRIPT_ARRAYS;
25657
25658 if(gptr > game->globalRAM.size())
25659 return;
25660 else set_register(sarg1,(game->globalRAM[gptr].Size() == 0) ? 0 : 10000); return;
25661 }
25662 else
25663 {
25664 565 set_register(sarg1,(localRAM[ptr].Size() == 0) ? 0 : 10000);
25665 }
25666 565 }
25667
25668 27033 void do_isvaliditem()
25669 {
25670 27033 int32_t IID = get_register(sarg1);
25671 //int32_t ct = items.Count();
25672
25673 //for ( int32_t j = items.Count()-1; j >= 0; --j )
25674
2/2
✓ Branch 0 taken 30321 times.
✓ Branch 1 taken 203 times.
30524 for(int32_t j = 0; j < items.Count(); j++)
25675 //for(int32_t j = 0; j < ct; j++)
25676
2/2
✓ Branch 0 taken 26830 times.
✓ Branch 1 taken 3491 times.
30321 if(items.spr(j)->getUID() == IID)
25677 {
25678 26830 set_register(sarg1, 10000);
25679 26830 return;
25680 }
25681
25682 203 set_register(sarg1, 0);
25683 27033 }
25684
25685 6259830 void do_isvalidnpc()
25686 {
25687 6259830 int32_t UID = get_register(sarg1);
25688 //for ( int32_t j = guys.Count()-1; j >= 0; --j )
25689 //int32_t ct = guys.Count();
25690
25691
2/2
✓ Branch 0 taken 20574989 times.
✓ Branch 1 taken 99922 times.
20674911 for(int32_t j = 0; j < guys.Count(); j++)
25692 //for(int32_t j = 0; j < ct; j++)
25693
2/2
✓ Branch 0 taken 6159908 times.
✓ Branch 1 taken 14415081 times.
20574989 if(guys.spr(j)->getUID() == UID)
25694 {
25695 6159908 set_register(sarg1, 10000);
25696 6159908 return;
25697 }
25698
25699 99922 set_register(sarg1, 0);
25700 6259830 }
25701
25702 593592 void do_isvalidlwpn()
25703 {
25704 593592 int32_t WID = get_register(sarg1);
25705 //int32_t ct = Lwpns.Count();
25706
25707 //for ( int32_t j = Lwpns.Count()-1; j >= 0; --j )
25708
2/2
✓ Branch 0 taken 2892378 times.
✓ Branch 1 taken 47556 times.
2939934 for(int32_t j = 0; j < Lwpns.Count(); j++)
25709 //for(int32_t j = 0; j < ct; j++)
25710
2/2
✓ Branch 0 taken 546036 times.
✓ Branch 1 taken 2346342 times.
2892378 if(Lwpns.spr(j)->getUID() == WID)
25711 {
25712 546036 set_register(sarg1, 10000);
25713 546036 return;
25714 }
25715
25716 47556 set_register(sarg1, 0);
25717 593592 }
25718
25719 122622 void do_isvalidewpn()
25720 {
25721 122622 int32_t WID = get_register(sarg1);
25722 // int32_t ct = Ewpns.Count();
25723
25724 // for ( int32_t j = Ewpns.Count()-1; j >= 0; --j )
25725
2/2
✓ Branch 0 taken 596698 times.
✓ Branch 1 taken 23727 times.
620425 for(int32_t j = 0; j < Ewpns.Count(); j++)
25726 //for(int32_t j = 0; j < ct; j++)
25727
2/2
✓ Branch 0 taken 98895 times.
✓ Branch 1 taken 497803 times.
596698 if(Ewpns.spr(j)->getUID() == WID)
25728 {
25729 98895 set_register(sarg1, 10000);
25730 98895 return;
25731 }
25732
25733 23727 set_register(sarg1, 0);
25734 122622 }
25735
25736 void do_lwpnmakeangular()
25737 {
25738 if(LwpnH::loadWeapon(ri->lwpn, "lweapon->MakeAngular") == SH::_NoError)
25739 {
25740 if (!LwpnH::getWeapon()->angular)
25741 {
25742 double vx;
25743 double vy;
25744 switch(NORMAL_DIR(LwpnH::getWeapon()->dir))
25745 {
25746 case l_up:
25747 case l_down:
25748 case left:
25749 vx = -1.0*((weapon*)s)->step;
25750 break;
25751 case r_down:
25752 case r_up:
25753 case right:
25754 vx = ((weapon*)s)->step;
25755 break;
25756
25757 default:
25758 vx = 0;
25759 break;
25760 }
25761 switch(NORMAL_DIR(LwpnH::getWeapon()->dir))
25762 {
25763 case l_up:
25764 case r_up:
25765 case up:
25766 vy = -1.0*((weapon*)s)->step;
25767 break;
25768 case l_down:
25769 case r_down:
25770 case down:
25771 vy = ((weapon*)s)->step;
25772 break;
25773
25774 default:
25775 vy = 0;
25776 break;
25777 }
25778 LwpnH::getWeapon()->angular = true;
25779 LwpnH::getWeapon()->angle=atan2(vy, vx);
25780 LwpnH::getWeapon()->step=FFCore.Distance(0, 0, vx, vy)/10000.0;
25781 LwpnH::getWeapon()->doAutoRotate();
25782 }
25783 }
25784 }
25785
25786 void do_lwpnmakedirectional()
25787 {
25788 if(LwpnH::loadWeapon(ri->lwpn, "lweapon->MakeDirectional") == SH::_NoError)
25789 {
25790 if (LwpnH::getWeapon()->angular)
25791 {
25792 LwpnH::getWeapon()->dir = NORMAL_DIR(AngleToDir(WrapAngle(LwpnH::getWeapon()->angle)));
25793 LwpnH::getWeapon()->angular = false;
25794 LwpnH::getWeapon()->doAutoRotate(true);
25795 }
25796 }
25797 }
25798
25799 void do_ewpnmakeangular()
25800 {
25801 if(EwpnH::loadWeapon(ri->ewpn, "eweapon->MakeAngular") == SH::_NoError)
25802 {
25803 if (!EwpnH::getWeapon()->angular)
25804 {
25805 double vx;
25806 double vy;
25807 switch(NORMAL_DIR(EwpnH::getWeapon()->dir))
25808 {
25809 case l_up:
25810 case l_down:
25811 case left:
25812 vx = -1.0*((weapon*)s)->step;
25813 break;
25814 case r_down:
25815 case r_up:
25816 case right:
25817 vx = ((weapon*)s)->step;
25818 break;
25819
25820 default:
25821 vx = 0;
25822 break;
25823 }
25824 switch(NORMAL_DIR(EwpnH::getWeapon()->dir))
25825 {
25826 case l_up:
25827 case r_up:
25828 case up:
25829 vy = -1.0*((weapon*)s)->step;
25830 break;
25831 case l_down:
25832 case r_down:
25833 case down:
25834 vy = ((weapon*)s)->step;
25835 break;
25836
25837 default:
25838 vy = 0;
25839 break;
25840 }
25841 EwpnH::getWeapon()->angular = true;
25842 EwpnH::getWeapon()->angle=atan2(vy, vx);
25843 EwpnH::getWeapon()->step=FFCore.Distance(0, 0, vx, vy)/10000.0;
25844 EwpnH::getWeapon()->doAutoRotate();
25845 }
25846 }
25847 }
25848
25849 void do_ewpnmakedirectional()
25850 {
25851 if(EwpnH::loadWeapon(ri->lwpn, "eweapon->MakeDirectional") == SH::_NoError)
25852 {
25853 if (EwpnH::getWeapon()->angular)
25854 {
25855 EwpnH::getWeapon()->dir = NORMAL_DIR(AngleToDir(WrapAngle(EwpnH::getWeapon()->angle)));
25856 EwpnH::getWeapon()->angular = false;
25857 EwpnH::getWeapon()->doAutoRotate(true);
25858 }
25859 }
25860 }
25861
25862 15079 void do_lwpnusesprite(const bool v)
25863 {
25864 15079 int32_t ID = SH::get_arg(sarg1, v) / 10000;
25865
25866
1/2
✓ Branch 0 taken 15079 times.
✗ Branch 1 not taken.
15079 if(BC::checkWeaponMiscSprite(ID, "lweapon->UseSprite") != SH::_NoError)
25867 return;
25868
25869
1/2
✓ Branch 0 taken 15079 times.
✗ Branch 1 not taken.
15079 if(LwpnH::loadWeapon(ri->lwpn, "lweapon->UseSprite") == SH::_NoError)
25870 15079 LwpnH::getWeapon()->LOADGFX(ID);
25871 15079 }
25872
25873 132144 void do_ewpnusesprite(const bool v)
25874 {
25875 132144 int32_t ID = SH::get_arg(sarg1, v) / 10000;
25876
25877
1/2
✓ Branch 0 taken 132144 times.
✗ Branch 1 not taken.
132144 if(BC::checkWeaponMiscSprite(ID, "eweapon->UseSprite") != SH::_NoError)
25878 return;
25879
25880
1/2
✓ Branch 0 taken 132144 times.
✗ Branch 1 not taken.
132144 if(EwpnH::loadWeapon(ri->ewpn, "eweapon->UseSprite") == SH::_NoError)
25881 132144 EwpnH::getWeapon()->LOADGFX(ID);
25882 132144 }
25883
25884 void do_portalusesprite()
25885 {
25886 int32_t ID = get_register(sarg1) / 10000;
25887
25888 if(BC::checkWeaponMiscSprite(ID, "portal->UseSprite") != SH::_NoError)
25889 return;
25890
25891 if(portal* p = checkPortal(ri->portalref, "UseSprite()"))
25892 p->LOADGFX(ID);
25893 }
25894
25895 void do_clearsprites(const bool v)
25896 {
25897 int32_t spritelist = SH::get_arg(sarg1, v) / 10000;
25898
25899 if(BC::checkBounds(spritelist, 0, 5, "Screen->ClearSprites") != SH::_NoError)
25900 return;
25901
25902 switch(spritelist)
25903 {
25904 case 0:
25905 guys.clear();
25906 break;
25907
25908 case 1:
25909 items.clear();
25910 break;
25911
25912 case 2:
25913 Ewpns.clear();
25914 break;
25915
25916 case 3:
25917 Lwpns.clear();
25918 Hero.reset_hookshot();
25919 break;
25920
25921 case 4:
25922 decorations.clear();
25923 break;
25924
25925 case 5:
25926 particles.clear();
25927 break;
25928 }
25929 }
25930
25931 1201098 void do_loadlweapon(const bool v)
25932 {
25933 1201098 int32_t index = SH::get_arg(sarg1, v) / 10000;
25934
25935
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 1187342 times.
1201098 if(BC::checkLWeaponIndex(index, "Screen->LoadLWeapon") != SH::_NoError)
25936 13756 ri->lwpn = 0; //MAX_DWORD; //Now NULL
25937 else
25938 {
25939 1187342 ri->lwpn = Lwpns.spr(index)->getUID();
25940 // This is too trivial to log. -L
25941 //Z_eventlog("Script loaded lweapon with UID = %ld\n", ri->lwpn);
25942 }
25943 1201098 }
25944
25945 2753647 void do_loadeweapon(const bool v)
25946 {
25947 2753647 int32_t index = SH::get_arg(sarg1, v) / 10000;
25948
25949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2753647 times.
2753647 if(BC::checkEWeaponIndex(index, "Screen->LoadEWeapon") != SH::_NoError)
25950 ri->ewpn = 0; //MAX_DWORD; //Now NULL
25951 else
25952 {
25953 2753647 ri->ewpn = Ewpns.spr(index)->getUID();
25954 //Z_eventlog("Script loaded eweapon with UID = %ld\n", ri->ewpn);
25955 }
25956 2753647 }
25957
25958 136832 void do_loaditem(const bool v)
25959 {
25960 136832 int32_t index = SH::get_arg(sarg1, v) / 10000;
25961
25962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136832 times.
136832 if(BC::checkItemIndex(index, "Screen->LoadItem") != SH::_NoError)
25963 ri->itemref = 0; //MAX_DWORD; //Now NULL
25964 else
25965 {
25966 136832 ri->itemref = items.spr(index)->getUID();
25967 //Z_eventlog("Script loaded item with UID = %ld\n", ri->itemref);
25968 }
25969 136832 }
25970
25971
25972 1816935 void do_loaditemdata(const bool v)
25973 {
25974 1816935 int32_t ID = SH::get_arg(sarg1, v) / 10000;
25975
25976 //I *think* this is the right check ~Joe
25977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1816935 times.
1816935 if(BC::checkItemID(ID, "Game->LoadItemData") != SH::_NoError)
25978 {
25979 ri->idata = -1; //new null value
25980 return;
25981 }
25982 1816935 ri->idata = ID;
25983 //Z_eventlog("Script loaded itemdata with ID = %ld\n", ri->idata);
25984 1816935 }
25985
25986 15641785 void do_loadnpc(const bool v)
25987 {
25988 15641785 int32_t index = SH::get_arg(sarg1, v) / 10000;
25989
25990
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 15641704 times.
15641785 if(BC::checkGuyIndex(index, "Screen->LoadNPC") != SH::_NoError)
25991 81 ri->guyref = 0; // MAX_DWORD;
25992 else
25993 {
25994 15641704 ri->guyref = guys.spr(index)->getUID();
25995 //Z_eventlog("Script loaded NPC with UID = %ld\n", ri->guyref);
25996 }
25997 15641785 }
25998
25999 800680 void FFScript::do_loaddmapdata(const bool v)
26000 {
26001 800680 int32_t ID = SH::get_arg(sarg1, v) / 10000;
26002
26003
2/4
✓ Branch 0 taken 800680 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 800680 times.
800680 if ( ID < 0 || ID > 511 )
26004 {
26005 Z_scripterrlog("Invalid DMap ID passed to Game->LoadDMapData(): %d\n", ID);
26006 ri->dmapsref = MAX_DWORD;
26007 }
26008
26009 800680 else ri->dmapsref = ID;
26010 //Z_eventlog("Script loaded npcdata with ID = %ld\n", ri->idata);
26011 800680 }
26012
26013 22 void FFScript::do_loadrng()
26014 {
26015 22 ri->rngref = get_free_rng();
26016 22 ri->d[rEXP1] = ri->rngref;
26017 22 }
26018
26019 void FFScript::do_loaddirectory()
26020 {
26021 int32_t arrayptr = get_register(sarg1) / 10000;
26022 string path;
26023 ArrayH::getString(arrayptr, path, 2048);
26024
26025 if(path.find("../") != string::npos
26026 || path.find("..\\") != string::npos)
26027 {
26028 Z_scripterrlog("Error: Script attempted to go up a directory in directory load '%s'\n", path.c_str());
26029 return;
26030 }
26031
26032 size_t pos = path.find_last_not_of("/\\");
26033 if(pos != string::npos && !(path.find_last_of("/\\") < pos))
26034 path = path.substr(0, pos+1);
26035 char buf[2048+1] = {0};
26036 get_scriptfile_path(buf, path.c_str());
26037 regulate_path(buf);
26038 if(valid_dir(buf) && checkPath(buf, true))
26039 {
26040 ri->directoryref = get_free_directory(false);
26041 if(!ri->directoryref) return;
26042 user_dir* d = checkDir(ri->directoryref, "LoadDirectory", true);
26043 set_register(sarg1, ri->directoryref);
26044 d->setPath(buf);
26045 return;
26046 }
26047 Z_scripterrlog("Path '%s' empty or points to a file; must point to a directory!\n",path.c_str());
26048 ri->directoryref = 0;
26049 set_register(sarg1, 0);
26050 }
26051
26052 void FFScript::do_loadstack()
26053 {
26054 ri->stackref = get_free_stack();
26055 ri->d[rEXP1] = ri->stackref;
26056 }
26057
26058 void FFScript::do_loaddropset(const bool v)
26059 {
26060 int32_t ID = SH::get_arg(sarg1, v) / 10000;
26061
26062 if ( ID < 0 || ID > MAXITEMDROPSETS )
26063 {
26064 Z_scripterrlog("Invalid Dropset ID passed to Game->LoadDropset(): %d\n", ID);
26065 ri->dropsetref = MAX_DWORD;
26066 }
26067
26068 else ri->dropsetref = ID;
26069 }
26070
26071 void FFScript::do_loadbottle(const bool v)
26072 {
26073 int32_t ID = SH::get_arg(sarg1, v) / 10000;
26074
26075 if ( ID < 1 || ID > 64 )
26076 {
26077 Z_scripterrlog("Invalid BottleType ID passed to Game->LoadBottleData(): %d\n", ID);
26078 ri->bottletyperef = 0;
26079 }
26080 else ri->bottletyperef = ID;
26081 }
26082
26083 void FFScript::do_loadbottleshop(const bool v)
26084 {
26085 int32_t ID = SH::get_arg(sarg1, v) / 10000;
26086
26087 if ( ID < 0 || ID > 255 )
26088 {
26089 Z_scripterrlog("Invalid BottleShopType ID passed to Game->LoadBottleShopData(): %d\n", ID);
26090 ri->bottleshopref = 0;
26091 }
26092 else ri->bottleshopref = ID+1;
26093 }
26094 68 void FFScript::do_loadgenericdata(const bool v)
26095 {
26096 68 int32_t ID = SH::get_arg(sarg1, v) / 10000;
26097
26098
2/4
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 68 times.
68 if ( ID < 1 || ID > NUMSCRIPTSGENERIC )
26099 {
26100 Z_scripterrlog("Invalid GenericData ID passed to Game->LoadGenericData(): %d\n", ID);
26101 ri->genericdataref = 0;
26102 }
26103 68 else ri->genericdataref = ID;
26104 68 }
26105
26106 void FFScript::do_create_paldata()
26107 {
26108 ri->paldataref = get_free_paldata();
26109 user_paldata* pd = &script_paldatas[ri->paldataref-1];
26110 for (int32_t q = 0; q < PALDATA_BITSTREAM_SIZE; ++q)
26111 pd->colors_used[q] = 0;
26112 ri->d[rEXP1] = ri->paldataref;
26113 }
26114
26115 void FFScript::do_create_paldata_clr()
26116 {
26117 ri->paldataref = get_free_paldata();
26118 user_paldata* pd = &script_paldatas[ri->paldataref - 1];
26119 int32_t clri = get_register(sarg1);
26120
26121 RGB c = _RGB((clri >> 16) & 0xFF, (clri >> 8) & 0xFF, clri & 0xFF);
26122
26123 if (c.r < 0 || c.g < 0 || c.b < 0)
26124 {
26125 Z_scripterrlog("Invalid rgb (%d) passed to Graphics->CreatePalData().\n", clri);
26126 }
26127 c.r = vbound(c.r, 0, 63);
26128 c.g = vbound(c.g, 0, 63);
26129 c.b = vbound(c.b, 0, 63);
26130
26131 for(int32_t q = 0; q < 240; ++q)
26132 pd->set_color(q, c);
26133 ri->d[rEXP1] = ri->paldataref;
26134 }
26135
26136 void FFScript::do_mix_clr()
26137 {
26138 int32_t clr_start = SH::read_stack(ri->sp + 3);
26139 int32_t clr_end = SH::read_stack(ri->sp + 2);
26140 float percent = SH::read_stack(ri->sp + 1) / 10000.0;
26141 int32_t color_space = SH::read_stack(ri->sp + 0) / 10000;
26142
26143 RGB ref1c = _RGB((clr_start >> 16) & 0xFF, (clr_start >> 8) & 0xFF, clr_start & 0xFF);
26144 RGB ref2c = _RGB((clr_end >> 16) & 0xFF, (clr_end >> 8) & 0xFF, clr_end & 0xFF);
26145 RGB outputc = user_paldata::mix_color(ref1c, ref2c, percent, color_space);
26146
26147 int32_t r = vbound(outputc.r, 0, 63);
26148 int32_t g = vbound(outputc.g, 0, 63);
26149 int32_t b = vbound(outputc.b, 0, 63);
26150
26151 ri->d[rEXP1] = (r << 16) | (g << 8) | b;
26152 }
26153
26154 void FFScript::do_create_rgb_hex()
26155 {
26156 int32_t hexrgb = get_register(sarg1);
26157
26158 int32_t r = (hexrgb >> 16) & 0xFF;
26159 int32_t g = (hexrgb >> 8) & 0xFF;
26160 int32_t b = hexrgb & 0xFF;
26161
26162 //Convert rgb from 8-bit to 6-bit
26163 r = vbound(r / 4, 0, 63);
26164 g = vbound(g / 4, 0, 63);
26165 b = vbound(b / 4, 0, 63);
26166
26167 ri->d[rEXP1] = (r << 16) | (g << 8) | b;
26168 }
26169
26170 void FFScript::do_create_rgb()
26171 {
26172 int32_t r = SH::read_stack(ri->sp + 2) / 10000;
26173 int32_t g = SH::read_stack(ri->sp + 1) / 10000;
26174 int32_t b = SH::read_stack(ri->sp + 0) / 10000;
26175
26176 if (unsigned(r) > 63 || unsigned(g) > 63 || unsigned(b) > 63)
26177 {
26178 Z_scripterrlog("R/G/B values passed to Graphics->CreateRGB() should range from 0-63.\n");
26179 }
26180 r = vbound(r, 0, 63);
26181 g = vbound(g, 0, 63);
26182 b = vbound(b, 0, 63);
26183
26184 ri->d[rEXP1] = (r << 16) | (g << 8) | b;
26185 }
26186
26187 void FFScript::do_convert_from_rgb()
26188 {
26189 int32_t buf = SH::read_stack(ri->sp + 2) / 10000;
26190 int32_t clri = SH::read_stack(ri->sp + 1);
26191 int32_t color_space = SH::read_stack(ri->sp + 0) / 10000;
26192
26193 ArrayManager am(buf);
26194 if (am.invalid()) return;
26195 int32_t zscript_array_size = am.size();
26196 int32_t target_size;
26197
26198 switch (color_space)
26199 {
26200 case user_paldata::CSPACE_CMYK:
26201 target_size = 4;
26202 break;
26203 default:
26204 target_size = 3;
26205 }
26206
26207 if (zscript_array_size < target_size)
26208 {
26209 Z_scripterrlog("Array supplied to 'Graphics->ConvertFromRGB' not large enough. Should be at least size %d\n", target_size);
26210 return;
26211 }
26212
26213 RGB c = _RGB((clri >> 16) & 0xFF, (clri >> 8) & 0xFF, clri & 0xFF);
26214 double convert[4];
26215 user_paldata::RGBTo(c, convert, color_space);
26216
26217 for (int32_t q = 0; q < target_size; ++q)
26218 {
26219 am.set(q, int32_t(convert[q]*10000));
26220 }
26221
26222 return;
26223 }
26224
26225 void FFScript::do_convert_to_rgb()
26226 {
26227 int32_t buf = SH::read_stack(ri->sp + 1) / 10000;
26228 int32_t color_space = SH::read_stack(ri->sp + 0) / 10000;
26229
26230 ArrayManager am(buf);
26231 if (am.invalid()) return;
26232 int32_t zscript_array_size = am.size();
26233 int32_t target_size;
26234
26235 switch (color_space)
26236 {
26237 case user_paldata::CSPACE_CMYK:
26238 target_size = 4;
26239 break;
26240 default:
26241 target_size = 3;
26242 }
26243
26244 if (zscript_array_size < target_size)
26245 {
26246 Z_scripterrlog("Array supplied to 'Graphics->ConvertToRGB' not large enough. Should be at least size %d\n", target_size);
26247 return;
26248 }
26249
26250 double convert[4];
26251 for (int32_t q = 0; q < target_size; ++q)
26252 {
26253 convert[q] = am.get(q) / 10000.0;
26254 }
26255 RGB c = user_paldata::RGBFrom(convert, color_space);
26256
26257 ri->d[rEXP1] = (c.r << 16) | (c.g << 8) | c.b;
26258 }
26259
26260 void FFScript::do_paldata_load_level()
26261 {
26262 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->LoadLevelPalette()"))
26263 {
26264 int32_t lvl = get_register(sarg1) / 10000;
26265 //Load CSets 2-4
26266 pd->load_cset(2, lvl * pdLEVEL + poLEVEL + 0);
26267 pd->load_cset(3, lvl * pdLEVEL + poLEVEL + 1);
26268 pd->load_cset(4, lvl * pdLEVEL + poLEVEL + 2);
26269 //Load CSet 9
26270 pd->load_cset(9, lvl * pdLEVEL + poLEVEL + 3);
26271 //Load 1, 5, 7, 8
26272 pd->load_cset(1, lvl * pdLEVEL + poNEWCSETS);
26273 pd->load_cset(5, lvl * pdLEVEL + poNEWCSETS + 1);
26274 pd->load_cset(7, lvl * pdLEVEL + poNEWCSETS + 2);
26275 pd->load_cset(8, lvl * pdLEVEL + poNEWCSETS + 3);
26276 }
26277 return;
26278 }
26279
26280 void FFScript::do_paldata_load_sprite()
26281 {
26282 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->LoadSpritePalette()"))
26283 {
26284 int32_t page = get_register(sarg1) / 10000;
26285
26286 int32_t pageoffset = 0;
26287 switch (page)
26288 {
26289 case 0: pageoffset += 0; break;
26290 case 1: pageoffset += 15; break;
26291 default:
26292 Z_scripterrlog("Invalid page (%d) passed to paldata->LoadSpritePalette(). Valid pages are 0 or 1. Aborting.\n", page);
26293 return;
26294 }
26295 for (int32_t q = 0; q < 15; ++q)
26296 {
26297 pd->load_cset(q, poSPRITE255 + pageoffset + q);
26298 }
26299 }
26300 return;
26301 }
26302
26303 void FFScript::do_paldata_load_main()
26304 {
26305 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->LoadMainPalette()"))
26306 {
26307 for (int32_t q = 0; q <= 15; ++q)
26308 {
26309 pd->load_cset_main(q);
26310 }
26311 }
26312 return;
26313 }
26314
26315 void FFScript::do_paldata_load_cycle()
26316 {
26317 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->LoadCyclePalette()"))
26318 {
26319 int32_t lvl = get_register(sarg1) / 10000;
26320 for (int32_t q = 4; q <= 12; ++q)
26321 {
26322 pd->load_cset(q, lvl * pdLEVEL + poLEVEL + q);
26323 }
26324 }
26325 return;
26326 }
26327
26328 void FFScript::do_paldata_load_bitmap()
26329 {
26330 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->LoadBitmapPalette()"))
26331 {
26332 int32_t pathptr = get_register(sarg1) / 10000;
26333 string str;
26334 ArrayH::getString(pathptr, str, 256);
26335
26336 if (get_qr(qr_BITMAP_AND_FILESYSTEM_PATHS_ALWAYS_RELATIVE))
26337 {
26338 char buf[2048+1] = { 0 };
26339 if (FFCore.get_scriptfile_path(buf, str.c_str()))
26340 str = buf;
26341 }
26342 regulate_path(str);
26343
26344 if (str.empty())
26345 {
26346 al_trace("String pointer is null! Internal error. \n");
26347 return;
26348 }
26349
26350 PALETTE tempPal;
26351 get_palette(tempPal);
26352 if (checkPath(str.c_str(), false))
26353 {
26354 BITMAP* bmp = load_bitmap(str.c_str(), tempPal);
26355 if (!bmp)
26356 {
26357 Z_scripterrlog("LoadBitmapPalette() failed to load image file %s.\n", str.c_str());
26358 }
26359 else
26360 {
26361 for (int32_t q = 0; q < PALDATA_NUM_COLORS; ++q)
26362 {
26363 pd->colors[q] = tempPal[q];
26364 set_bit(pd->colors_used, q, true);
26365 }
26366 }
26367 destroy_bitmap(bmp);
26368 }
26369 else
26370 {
26371 Z_scripterrlog("Failed to load image file: %s. File not found.\n", str.c_str());
26372 }
26373 }
26374 return;
26375 }
26376
26377 void FFScript::do_paldata_write_level()
26378 {
26379 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteLevelPalette()"))
26380 {
26381 int32_t lvl = get_register(sarg1) / 10000;
26382 bool changed = false;
26383 //Write CSets 2-4
26384 if (pd->check_cset(2, lvl * pdLEVEL + poLEVEL + 0))
26385 {
26386 pd->write_cset(2, lvl * pdLEVEL + poLEVEL + 0);
26387 changed = true;
26388 }
26389 if (pd->check_cset(3, lvl * pdLEVEL + poLEVEL + 1))
26390 {
26391 pd->write_cset(3, lvl * pdLEVEL + poLEVEL + 1);
26392 changed = true;
26393 }
26394 if (pd->check_cset(4, lvl * pdLEVEL + poLEVEL + 2))
26395 {
26396 pd->write_cset(4, lvl * pdLEVEL + poLEVEL + 2);
26397 changed = true;
26398 }
26399 //Write CSet 9
26400 if (pd->check_cset(9, lvl * pdLEVEL + poLEVEL + 3))
26401 {
26402 pd->write_cset(9, lvl * pdLEVEL + poLEVEL + 3);
26403 changed = true;
26404 }
26405 //Write 1, 5, 7, 8
26406 if (pd->check_cset(1, lvl * pdLEVEL + poNEWCSETS + 0))
26407 {
26408 pd->write_cset(1, lvl * pdLEVEL + poNEWCSETS + 0);
26409 changed = true;
26410 }
26411 if (pd->check_cset(5, lvl * pdLEVEL + poNEWCSETS + 1))
26412 {
26413 pd->write_cset(5, lvl * pdLEVEL + poNEWCSETS + 1);
26414 changed = true;
26415 }
26416 if (pd->check_cset(7, lvl * pdLEVEL + poNEWCSETS + 2))
26417 {
26418 pd->write_cset(7, lvl * pdLEVEL + poNEWCSETS + 2);
26419 changed = true;
26420 }
26421 if (pd->check_cset(8, lvl * pdLEVEL + poNEWCSETS + 3))
26422 {
26423 pd->write_cset(8, lvl * pdLEVEL + poNEWCSETS + 3);
26424 changed = true;
26425 }
26426
26427 if (changed && DMaps[currdmap].color == lvl)
26428 {
26429 loadlvlpal(lvl);
26430 currcset = lvl;
26431 if (darkroom && !get_qr(qr_NEW_DARKROOM))
26432 {
26433 if (get_qr(qr_FADE))
26434 {
26435 interpolatedfade();
26436 }
26437 else
26438 {
26439 loadfadepal((DMaps[currdmap].color) * pdLEVEL + poFADE3);
26440 }
26441 }
26442 }
26443 }
26444 return;
26445 }
26446
26447 void FFScript::do_paldata_write_levelcset()
26448 {
26449 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteLevelCSet()"))
26450 {
26451 int32_t lvl = get_register(sarg1) / 10000;
26452 int32_t cs = get_register(sarg2) / 10000;
26453
26454 bool changed = false;
26455
26456 switch (cs)
26457 {
26458 case 1:
26459 if (pd->check_cset(1, lvl * pdLEVEL + poNEWCSETS + 0))
26460 {
26461 pd->write_cset(1, lvl * pdLEVEL + poNEWCSETS + 0);
26462 changed = true;
26463 }
26464 break;
26465 case 2:
26466 if (pd->check_cset(2, lvl * pdLEVEL + poLEVEL + 0))
26467 {
26468 pd->write_cset(2, lvl * pdLEVEL + poLEVEL + 0);
26469 changed = true;
26470 }
26471 break;
26472 case 3:
26473 if (pd->check_cset(3, lvl * pdLEVEL + poLEVEL + 1))
26474 {
26475 pd->write_cset(3, lvl * pdLEVEL + poLEVEL + 1);
26476 changed = true;
26477 }
26478 break;
26479 case 4:
26480 if (pd->check_cset(4, lvl * pdLEVEL + poLEVEL + 2))
26481 {
26482 pd->write_cset(4, lvl * pdLEVEL + poLEVEL + 2);
26483 changed = true;
26484 }
26485 break;
26486 case 5:
26487 if (pd->check_cset(5, lvl * pdLEVEL + poNEWCSETS + 1))
26488 {
26489 pd->write_cset(5, lvl * pdLEVEL + poNEWCSETS + 1);
26490 changed = true;
26491 }
26492 break;
26493 case 7:
26494 if (pd->check_cset(7, lvl * pdLEVEL + poNEWCSETS + 2))
26495 {
26496 pd->write_cset(7, lvl * pdLEVEL + poNEWCSETS + 2);
26497 changed = true;
26498 }
26499 break;
26500 case 8:
26501 if (pd->check_cset(8, lvl * pdLEVEL + poNEWCSETS + 3))
26502 {
26503 pd->write_cset(8, lvl * pdLEVEL + poNEWCSETS + 3);
26504 changed = true;
26505 }
26506 break;
26507 case 9:
26508 if (pd->check_cset(9, lvl * pdLEVEL + poLEVEL + 3))
26509 {
26510 pd->write_cset(9, lvl * pdLEVEL + poLEVEL + 3);
26511 changed = true;
26512 }
26513 break;
26514 default:
26515 Z_scripterrlog("Invalid CSet (%d) passed to 'paldata->WriteLevelCSet()'. Level palettes can use CSets 1, 2, 3, 4, 5, 7, 8, 9.\n");
26516 return;
26517 }
26518
26519 if (changed && DMaps[currdmap].color == lvl)
26520 {
26521 loadlvlpal(lvl);
26522 if (darkroom && !get_qr(qr_NEW_DARKROOM))
26523 {
26524 if (get_qr(qr_FADE))
26525 {
26526 interpolatedfade();
26527 }
26528 else
26529 {
26530 loadfadepal((DMaps[currdmap].color) * pdLEVEL + poFADE3);
26531 }
26532 }
26533 currcset = lvl;
26534 }
26535 }
26536 }
26537
26538 void FFScript::do_paldata_write_sprite()
26539 {
26540 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteSpritePalette()"))
26541 {
26542 int32_t page = get_register(sarg1) / 10000;
26543
26544 int32_t pageoffset = 0;
26545 switch (page)
26546 {
26547 case 0: pageoffset += 0; break;
26548 case 1: pageoffset += 15; break;
26549 default:
26550 Z_scripterrlog("Invalid page (%d) passed to paldata->WriteSpritePalette(). Valid pages are 0 or 1. Aborting.\n", page);
26551 return;
26552 }
26553 bool changed6 = false;
26554 bool changed14 = false;
26555 for (int32_t q = 0; q < 15; ++q)
26556 {
26557 if (pd->check_cset(q, poSPRITE255 + pageoffset + q))
26558 {
26559 pd->write_cset(q, poSPRITE255 + pageoffset + q);
26560 if (pageoffset + q == currspal6)
26561 {
26562 changed6 = true;
26563 }
26564 if (pageoffset + q == currspal14)
26565 {
26566 changed14 = true;
26567 }
26568 }
26569 }
26570
26571 //If either sprite palette has been changed, update the main palette
26572 if (changed6 || changed14)
26573 {
26574 if (changed6)
26575 {
26576 loadpalset(6, poSPRITE255 + currspal6, false);
26577 }
26578 if (changed14)
26579 {
26580 loadpalset(14, poSPRITE255 + currspal14, false);
26581 }
26582
26583 if (isMonochrome()) {
26584 if (lastMonoPreset) {
26585 restoreMonoPreset();
26586 }
26587 else {
26588 setMonochrome(false);
26589 setMonochrome(true);
26590 }
26591 }
26592
26593 if (isUserTinted()) {
26594 restoreTint();
26595 }
26596 }
26597 }
26598 return;
26599 }
26600
26601 void FFScript::do_paldata_write_spritecset()
26602 {
26603 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteSpritePalette()"))
26604 {
26605 int32_t page = get_register(sarg1) / 10000;
26606 int32_t cs = get_register(sarg2) / 10000;
26607
26608 int32_t pageoffset = 0;
26609 switch (page)
26610 {
26611 case 0: pageoffset += 0; break;
26612 case 1: pageoffset += 15; break;
26613 default:
26614 Z_scripterrlog("Invalid page (%d) passed to paldata->WriteSpriteCSet(). Valid pages are 0 or 1. Aborting.\n", page);
26615 return;
26616 }
26617 bool changed6 = false;
26618 bool changed14 = false;
26619 if (unsigned(cs) > 15)
26620 {
26621 Z_scripterrlog("Invalid CSet (%d) passed to paldata->WriteSpriteCSet(). Valid CSets are 0-15. Aborting.\n", cs);
26622 return;
26623 }
26624 if (pd->check_cset(cs, poSPRITE255 + pageoffset + cs))
26625 {
26626 pd->write_cset(cs, poSPRITE255 + pageoffset + cs);
26627 if (pageoffset + cs == currspal6)
26628 {
26629 changed6 = true;
26630 }
26631 if (pageoffset + cs == currspal14)
26632 {
26633 changed14 = true;
26634 }
26635 }
26636
26637 //If either sprite palette has been changed, update the main palette
26638 if (changed6 || changed14)
26639 {
26640 if (changed6)
26641 {
26642 loadpalset(6, poSPRITE255 + currspal6, false);
26643 }
26644 if (changed14)
26645 {
26646 loadpalset(14, poSPRITE255 + currspal14, false);
26647 }
26648
26649 if (isMonochrome()) {
26650 if (lastMonoPreset) {
26651 restoreMonoPreset();
26652 }
26653 else {
26654 setMonochrome(false);
26655 setMonochrome(true);
26656 }
26657 }
26658
26659 if (isUserTinted()) {
26660 restoreTint();
26661 }
26662 }
26663 }
26664 return;
26665 }
26666
26667 void FFScript::do_paldata_write_main()
26668 {
26669 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteMainPalette()"))
26670 {
26671 bool changed = false;
26672 for (int32_t q = 0; q <= 15; ++q)
26673 {
26674 if (pd->check_cset_main(q))
26675 {
26676 pd->write_cset_main(q);
26677 changed = true;
26678 }
26679 }
26680
26681 if (changed)
26682 {
26683 refreshpal = true;
26684 }
26685 }
26686 return;
26687 }
26688
26689 void FFScript::do_paldata_write_maincset()
26690 {
26691 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteMainCSet()"))
26692 {
26693 int32_t cs = get_register(sarg1) / 10000;
26694
26695 bool changed = false;
26696
26697 if (unsigned(cs) < 16)
26698 {
26699 if (pd->check_cset_main(cs))
26700 {
26701 pd->write_cset_main(cs);
26702 changed = true;
26703 }
26704 }
26705 else
26706 {
26707 Z_scripterrlog("Invalid CSet (%d) passed to 'paldata->WriteMainCSet()'. Valid csets are 0-15. Aborting.\n");
26708 return;
26709 }
26710
26711 if (changed)
26712 {
26713 refreshpal = true;
26714 }
26715 }
26716 }
26717
26718 void FFScript::do_paldata_write_cycle()
26719 {
26720 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteCyclePalette()"))
26721 {
26722 int32_t lvl = get_register(sarg1) / 10000;
26723 for (int32_t q = 4; q <= 12; ++q)
26724 {
26725 if (pd->check_cset(q, lvl * pdLEVEL + poLEVEL + q))
26726 {
26727 pd->write_cset(q, lvl * pdLEVEL + poLEVEL + q);
26728 }
26729 }
26730 }
26731 return;
26732 }
26733
26734 void FFScript::do_paldata_write_cyclecset()
26735 {
26736 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteCycleCSet()"))
26737 {
26738 int32_t lvl = get_register(sarg1) / 10000;
26739 int32_t cs = get_register(sarg2) / 10000;
26740
26741 bool changed = false;
26742
26743 switch (cs)
26744 {
26745 case 4:
26746 case 5:
26747 case 6:
26748 case 7:
26749 case 8:
26750 case 9:
26751 case 10:
26752 case 11:
26753 case 12:
26754 if (pd->check_cset(cs, lvl * pdLEVEL + poLEVEL + cs))
26755 {
26756 pd->write_cset(cs, lvl * pdLEVEL + poLEVEL + cs);
26757 changed = true;
26758 }
26759 break;
26760 default:
26761 Z_scripterrlog("Invalid CSet (%d) passed to 'paldata->WriteCycleCSet()'. Cycle palettes use CSets 4-12.\n");
26762 return;
26763 }
26764
26765 if (changed && DMaps[currdmap].color == lvl)
26766 {
26767 loadlvlpal(lvl);
26768 currcset = lvl;
26769 }
26770 }
26771 }
26772
26773 void FFScript::do_paldata_colorvalid()
26774 {
26775 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->ColorValid()"))
26776 {
26777 int32_t ind = get_register(sarg1) / 10000;
26778 if (unsigned(ind) >= PALDATA_NUM_COLORS)
26779 {
26780 Z_scripterrlog("Invalid color index (%d) passed to paldata->ColorValid(). Valid indices are 0-255.\n", ind);
26781 set_register(sarg1, 0);
26782 return;
26783 }
26784
26785 if (get_bit(pd->colors_used, ind))
26786 {
26787 set_register(sarg1, 10000);
26788 }
26789 else
26790 {
26791 set_register(sarg1, 0);
26792 }
26793 }
26794 }
26795
26796 void FFScript::do_paldata_clearcolor()
26797 {
26798 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->SetColor()"))
26799 {
26800 int32_t ind = get_register(sarg1) / 10000;
26801 if (unsigned(ind) >= PALDATA_NUM_COLORS)
26802 {
26803 Z_scripterrlog("Invalid color index (%d) passed to paldata->ClearColor(). Valid indices are 0-255. Aborting.\n", ind);
26804 return;
26805 }
26806 set_bit(pd->colors_used, ind, false);
26807 }
26808 }
26809
26810 void FFScript::do_paldata_clearcset()
26811 {
26812 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->ClearCSet()"))
26813 {
26814 int32_t cs = get_register(sarg1) / 10000;
26815 if (unsigned(cs) > 15)
26816 {
26817 Z_scripterrlog("Invalid cset (%d) passed to paldata->ClearCSet(). Valid csets are 0-15. Aborting.\n", cs);
26818 return;
26819 }
26820 for (int32_t q = 0; q < 16; ++q)
26821 {
26822 set_bit(pd->colors_used, CSET(cs) + q, false);
26823 }
26824 }
26825 }
26826
26827 int32_t FFScript::do_paldata_getrgb(int32_t v)
26828 {
26829 const char* fname = "";
26830 switch (v)
26831 {
26832 case 0: fname = "paldata->R[]"; break;
26833 case 1: fname = "paldata->G[]"; break;
26834 case 2: fname = "paldata->B[]"; break;
26835 }
26836 if (user_paldata* pd = checkPalData(ri->paldataref, fname))
26837 {
26838 int32_t ind = ri->d[rINDEX] / 10000;
26839 if (unsigned(ind) >= PALDATA_NUM_COLORS)
26840 {
26841 Z_scripterrlog("Invalid color index (%d) passed to %s. Valid indices are 0-255.\n", ind, fname);
26842 return -10000;
26843 }
26844 if (!get_bit(pd->colors_used, ind))
26845 {
26846 Z_scripterrlog("%s tried to access unused color %d.\n", fname, ind);
26847 return -10000;
26848 }
26849 switch (v)
26850 {
26851 case 0:
26852 return pd->colors[ind].r * 10000;
26853 case 1:
26854 return pd->colors[ind].g * 10000;
26855 case 2:
26856 return pd->colors[ind].b * 10000;
26857 }
26858 }
26859 return -10000;
26860 }
26861
26862 void FFScript::do_paldata_setrgb(int32_t v, int32_t val)
26863 {
26864 const char* fname = "";
26865 switch (v)
26866 {
26867 case 0: fname = "paldata->R[]"; break;
26868 case 1: fname = "paldata->G[]"; break;
26869 case 2: fname = "paldata->B[]"; break;
26870 }
26871 if (user_paldata* pd = checkPalData(ri->paldataref, fname))
26872 {
26873 int32_t ind = ri->d[rINDEX] / 10000;
26874 if (unsigned(ind) >= PALDATA_NUM_COLORS)
26875 {
26876 Z_scripterrlog("Invalid color index (%d) passed to %s. Valid indices are 0-255. Aborting.\n", ind, fname);
26877 return;
26878 }
26879 if (unsigned(val) > 63)
26880 {
26881 Z_scripterrlog("RGB value(%d) passed to %s is out of range. RGB values range from 0 - 63.\n", val, fname);
26882 val = vbound(val, 0, 63);
26883 }
26884 if (!get_bit(pd->colors_used, ind))
26885 {
26886 Z_scripterrlog("%s tried to access unused color %d.\n", fname, ind);
26887 return;
26888 }
26889 switch (v)
26890 {
26891 case 0:
26892 pd->colors[ind].r = val;
26893 break;
26894 case 1:
26895 pd->colors[ind].g = val;
26896 break;
26897 case 2:
26898 pd->colors[ind].b = val;
26899 break;
26900 }
26901 }
26902 }
26903
26904 void FFScript::do_paldata_mix()
26905 {
26906 int32_t ref = SH::read_stack(ri->sp + 4);
26907 if (user_paldata* pd = checkPalData(ref, "paldata->Mix()"))
26908 {
26909 int32_t ref1 = SH::read_stack(ri->sp + 3);
26910 int32_t ref2 = SH::read_stack(ri->sp + 2);
26911 double percent = SH::read_stack(ri->sp + 1)/10000.0;
26912 int32_t color_space = SH::read_stack(ri->sp + 0)/10000;
26913 if (user_paldata* pd_start = checkPalData(ref1, "paldata->Mix()"))
26914 {
26915 if (user_paldata* pd_end = checkPalData(ref2, "paldata->Mix()"))
26916 {
26917 pd->mix(pd_start, pd_end, percent, color_space);
26918 }
26919 }
26920 }
26921 }
26922
26923 void FFScript::do_paldata_mixcset()
26924 {
26925 int32_t ref = SH::read_stack(ri->sp + 5);
26926 if (user_paldata* pd = checkPalData(ref, "paldata->MixCSet()"))
26927 {
26928 int32_t ref1 = SH::read_stack(ri->sp + 4);
26929 int32_t ref2 = SH::read_stack(ri->sp + 3);
26930 int32_t cset = SH::read_stack(ri->sp + 2) / 10000;
26931 double percent = SH::read_stack(ri->sp + 1) / 10000.0;
26932 int32_t color_space = SH::read_stack(ri->sp + 0) / 10000;
26933 if (user_paldata* pd_start = checkPalData(ref1, "paldata->MixCSet()"))
26934 {
26935 if (user_paldata* pd_end = checkPalData(ref2, "paldata->MixCSet()"))
26936 {
26937 if (unsigned(cset) > 15)
26938 {
26939 Z_scripterrlog("CSet passed to 'paldata->MixCSet()' out of range. Valid CSets are 0-15\n");
26940 return;
26941 }
26942 pd->mix(pd_start, pd_end, percent, color_space, CSET(cset), CSET(cset) + 16);
26943 }
26944 }
26945 }
26946 }
26947
26948 void FFScript::do_paldata_copy()
26949 {
26950 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->Copy()"))
26951 {
26952 int32_t ref_dest = get_register(sarg1);
26953 if (user_paldata* pd_dest = checkPalData(ref_dest, "paldata->Copy()"))
26954 {
26955 for (int32_t q = 0; q < PALDATA_NUM_COLORS; ++q)
26956 {
26957 pd_dest->colors[q] = pd->colors[q];
26958 }
26959 for (int32_t q = 0; q < PALDATA_BITSTREAM_SIZE; ++q)
26960 {
26961 pd_dest->colors_used[q] = pd->colors_used[q];
26962 }
26963 }
26964 }
26965 }
26966
26967 void FFScript::do_paldata_copycset()
26968 {
26969 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->CopyCSet()"))
26970 {
26971 int32_t ref_dest = SH::read_stack(ri->sp + 2);
26972 int32_t cs = SH::read_stack(ri->sp + 1) / 10000;
26973 int32_t cs_dest = SH::read_stack(ri->sp + 0) / 10000;
26974 if (user_paldata* pd_dest = checkPalData(ref_dest, "paldata->CopyCSet()"))
26975 {
26976 if (unsigned(cs) > 15)
26977 {
26978 Z_scripterrlog("Invalid CSet (%d) passed to paldata->CopyCSet(). Valid CSets are 0-15. Aborting.\n", cs);
26979 return;
26980 }
26981 for (int32_t q = 0; q < 16; ++q)
26982 {
26983 pd_dest->colors[CSET(cs_dest) + q] = pd->colors[CSET(cs) + q];
26984 set_bit(pd_dest->colors_used, CSET(cs_dest) + q, bool(get_bit(pd->colors_used, CSET(cs) + q)));
26985 }
26986 }
26987 }
26988 }
26989
26990 //Loads a cset to paldata from memory
26991 void user_paldata::load_cset(int32_t cset, int32_t dataset)
26992 {
26993 byte* si = colordata + CSET(dataset) * 3;
26994 for (int32_t q = 0; q < 16; ++q)
26995 {
26996 int32_t ind = CSET(cset) + q;
26997 colors[ind].r = si[0];
26998 colors[ind].g = si[1];
26999 colors[ind].b = si[2];
27000 set_bit(colors_used, ind, true);
27001 si += 3;
27002 }
27003 }
27004
27005 //Loads a cset to paldata from the main palette
27006 void user_paldata::load_cset_main(int32_t cset)
27007 {
27008 for (int32_t q = 0; q < 16; ++q)
27009 {
27010 int32_t ind = CSET(cset) + q;
27011 colors[ind].r = RAMpal[ind].r;
27012 colors[ind].g = RAMpal[ind].g;
27013 colors[ind].b = RAMpal[ind].b;
27014 set_bit(colors_used, ind, true);
27015 }
27016 }
27017
27018 //Writes to a memory cset from paldata
27019 void user_paldata::write_cset(int32_t cset, int32_t dataset)
27020 {
27021 byte* si = colordata + CSET(dataset) * 3;
27022 for (int32_t q = 0; q < 16; ++q)
27023 {
27024 int32_t ind = CSET(cset) + q;
27025 if (get_bit(colors_used, ind))
27026 {
27027 si[0] = colors[ind].r;
27028 si[1] = colors[ind].g;
27029 si[2] = colors[ind].b;
27030 }
27031 si += 3;
27032 }
27033 }
27034
27035 //Writes to a main palette cset from paldata
27036 void user_paldata::write_cset_main(int32_t cset)
27037 {
27038 for (int32_t q = 0; q < 16; ++q)
27039 {
27040 int32_t ind = CSET(cset) + q;
27041 if (get_bit(colors_used, ind))
27042 {
27043 RAMpal[ind] = colors[ind];
27044 }
27045 }
27046 }
27047
27048
27049 //Checks a memory cset from
27050
27051
27052
27053
27054 bool user_paldata::check_cset(int32_t cset, int32_t dataset)
27055 {
27056 byte* si = colordata + CSET(dataset) * 3;
27057 for (int32_t q = 0; q < 16; ++q)
27058 {
27059 int32_t ind = CSET(cset) + q;
27060 if (get_bit(colors_used, ind))
27061 {
27062 if (si[0] != colors[ind].r)
27063 return true;
27064 if (si[1] != colors[ind].g)
27065 return true;
27066 if (si[2] != colors[ind].b)
27067 return true;
27068 }
27069 si += 3;
27070 }
27071 return false;
27072 }
27073
27074 //Checks a memory cset from the main palette
27075 bool user_paldata::check_cset_main(int32_t cset)
27076 {
27077 for (int32_t q = 0; q < 16; ++q)
27078 {
27079 int32_t ind = CSET(cset) + q;
27080 if (get_bit(colors_used, ind))
27081 {
27082 if (RAMpal[ind].r != colors[ind].r)
27083 return true;
27084 if (RAMpal[ind].g != colors[ind].g)
27085 return true;
27086 if (RAMpal[ind].b != colors[ind].b)
27087 return true;
27088 }
27089 }
27090 return false;
27091 }
27092
27093 //Mixes a color between two paldatas
27094 RGB user_paldata::mix_color(RGB start, RGB end, double percent, int32_t color_space)
27095 {
27096 int32_t direction = 0;
27097 switch (color_space)
27098 {
27099 case CSPACE_RGB:
27100 return _RGB(byte(vbound(double(zc::math::Lerp(start.r, end.r, percent)), 0.0, 63.0)),
27101 byte(vbound(double(zc::math::Lerp(start.g, end.g, percent)), 0.0, 63.0)),
27102 byte(vbound(double(zc::math::Lerp(start.b, end.b, percent)), 0.0, 63.0)));
27103 case CSPACE_CMYK:
27104 {
27105 double convert_start[4];
27106 double convert_end[4];
27107 double convert_result[4];
27108 RGBTo(start, convert_start, color_space);
27109 RGBTo(end, convert_end, color_space);
27110 convert_result[0] = zc::math::Lerp(convert_start[0], convert_end[0], percent);
27111 convert_result[1] = zc::math::Lerp(convert_start[1], convert_end[1], percent);
27112 convert_result[2] = zc::math::Lerp(convert_start[2], convert_end[2], percent);
27113 convert_result[3] = zc::math::Lerp(convert_start[3], convert_end[3], percent);
27114 return RGBFrom(convert_result, color_space);
27115 }
27116 case CSPACE_HSV_CW:
27117 if (color_space == CSPACE_HSV_CW)
27118 direction = 1;
27119 [[fallthrough]];
27120 case CSPACE_HSV_CCW:
27121 if (color_space == CSPACE_HSV_CCW)
27122 direction = -1;
27123 [[fallthrough]];
27124 case CSPACE_HSV:
27125 {
27126 double convert_start[3];
27127 double convert_end[3];
27128 double convert_result[3];
27129 RGBTo(start, convert_start, color_space);
27130 RGBTo(end, convert_end, color_space);
27131 convert_result[0] = WrapLerp(convert_start[0], convert_end[0], percent, 0.0, 1.0, direction);
27132 convert_result[1] = zc::math::Lerp(convert_start[1], convert_end[1], percent);
27133 convert_result[2] = zc::math::Lerp(convert_start[2], convert_end[2], percent);
27134 return RGBFrom(convert_result, color_space);
27135 }
27136 case CSPACE_HSL_CW:
27137 if (color_space == CSPACE_HSL_CW)
27138 direction = 1;
27139 [[fallthrough]];
27140 case CSPACE_HSL_CCW:
27141 if (color_space == CSPACE_HSL_CCW)
27142 direction = -1;
27143 [[fallthrough]];
27144 case CSPACE_HSL:
27145 {
27146 double convert_start[3];
27147 double convert_end[3];
27148 double convert_result[3];
27149 RGBTo(start, convert_start, color_space);
27150 RGBTo(end, convert_end, color_space);
27151 convert_result[0] = WrapLerp(convert_start[0], convert_end[0], percent, 0.0, 1.0, direction);
27152 convert_result[1] = zc::math::Lerp(convert_start[1], convert_end[1], percent);
27153 convert_result[2] = zc::math::Lerp(convert_start[2], convert_end[2], percent);
27154 return RGBFrom(convert_result, color_space);
27155 }
27156 case CSPACE_LAB:
27157 {
27158 double convert_start[3];
27159 double convert_end[3];
27160 double convert_result[3];
27161 RGBTo(start, convert_start, color_space);
27162 RGBTo(end, convert_end, color_space);
27163 convert_result[0] = zc::math::Lerp(convert_start[0], convert_end[0], percent);
27164 convert_result[1] = zc::math::Lerp(convert_start[1], convert_end[1], percent);
27165 convert_result[2] = zc::math::Lerp(convert_start[2], convert_end[2], percent);
27166 return RGBFrom(convert_result, color_space);
27167 }
27168 case CSPACE_LCH_CW:
27169 if (color_space == CSPACE_LCH_CW)
27170 direction = 1;
27171 [[fallthrough]];
27172 case CSPACE_LCH_CCW:
27173 if (color_space == CSPACE_LCH_CCW)
27174 direction = -1;
27175 [[fallthrough]];
27176 case CSPACE_LCH:
27177 {
27178 double convert_start[3];
27179 double convert_end[3];
27180 double convert_result[3];
27181 RGBTo(start, convert_start, color_space);
27182 RGBTo(end, convert_end, color_space);
27183 convert_result[0] = zc::math::Lerp(convert_start[0], convert_end[0], percent);
27184 convert_result[1] = zc::math::Lerp(convert_start[1], convert_end[1], percent);
27185 convert_result[2] = WrapLerp(convert_start[2], convert_end[2], percent, 0.0, 360.0, direction);
27186 return RGBFrom(convert_result, color_space);
27187 }
27188 }
27189 return start;
27190 }
27191
27192 void user_paldata::RGBTo(RGB c, double arr[], int32_t color_space)
27193 {
27194 //From easyrgb.com/en/math.php
27195 double r = vbound(c.r / 63.0, 0.0, 1.0);
27196 double g = vbound(c.g / 63.0, 0.0, 1.0);
27197 double b = vbound(c.b / 63.0, 0.0, 1.0);
27198 switch (color_space)
27199 {
27200 case CSPACE_CMYK:
27201 {
27202 double c = 1.0 - r;
27203 double m = 1.0 - g;
27204 double y = 1.0 - b;
27205
27206 double k = 1.0;
27207
27208 if (c < k) k = c;
27209 if (m < k) k = m;
27210 if (y < k) k = y;
27211 if (k == 1)
27212 {
27213 c = 0.0;
27214 m = 0.0;
27215 y = 0.0;
27216 }
27217 else
27218 {
27219 c = (c - k) / (1.0 - k);
27220 m = (m - k) / (1.0 - k);
27221 y = (y - k) / (1.0 - k);
27222 }
27223 arr[0] = c;
27224 arr[1] = m;
27225 arr[2] = y;
27226 arr[3] = k;
27227 break;
27228 }
27229 case CSPACE_HSV_CW:
27230 case CSPACE_HSV_CCW:
27231 case CSPACE_HSV:
27232 {
27233 double min_val = std::min(std::min(r, g), b);
27234 double max_val = std::max(std::max(r, g), b);
27235 double del_max = max_val - min_val;
27236
27237 double h = 0;
27238 double s = 0;
27239 double v = max_val;
27240
27241 if (del_max != 0) //Set chroma if not gray
27242 {
27243 s = del_max / max_val;
27244
27245 double del_r = (((max_val - r) / 6.0) + (del_max / 2.0)) / del_max;
27246 double del_g = (((max_val - g) / 6.0) + (del_max / 2.0)) / del_max;
27247 double del_b = (((max_val - b) / 6.0) + (del_max / 2.0)) / del_max;
27248
27249 if (r == max_val) h = del_b - del_g;
27250 else if (g == max_val) h = (1.0 / 3.0) + del_r - del_b;
27251 else if (b == max_val) h = (2.0 / 3.0) + del_g - del_r;
27252
27253 if (h < 0) ++h;
27254 if (h > 1) --h;
27255 }
27256
27257 arr[0] = h;
27258 arr[1] = s;
27259 arr[2] = v;
27260 break;
27261 }
27262 case CSPACE_HSL_CW:
27263 case CSPACE_HSL_CCW:
27264 case CSPACE_HSL:
27265 {
27266 double min_val = std::min(std::min(r, g), b);
27267 double max_val = std::max(std::max(r, g), b);
27268 double del_max = max_val - min_val;
27269
27270 double h = 0;
27271 double s = 0;
27272 double l = (max_val + min_val) / 2.0;
27273
27274 if (del_max != 0) //Set chroma if not gray
27275 {
27276 if (l < 0.5) s = del_max / (max_val + min_val);
27277 else s = del_max / (2 - max_val - min_val);
27278
27279 double del_r = (((max_val - r) / 6.0) + (del_max / 2.0)) / del_max;
27280 double del_g = (((max_val - g) / 6.0) + (del_max / 2.0)) / del_max;
27281 double del_b = (((max_val - b) / 6.0) + (del_max / 2.0)) / del_max;
27282
27283 if (r == max_val) h = del_b - del_g;
27284 else if (g == max_val) h = (1.0 / 3.0) + del_r - del_b;
27285 else if (b == max_val) h = (2.0 / 3.0) + del_g - del_r;
27286
27287 if (h < 0) ++h;
27288 if (h > 1) --h;
27289 }
27290
27291 arr[0] = h;
27292 arr[1] = s;
27293 arr[2] = l;
27294 break;
27295 }
27296 case CSPACE_LAB:
27297 {
27298 if (r > 0.04045) r = pow(((r + 0.055) / 1.055), 2.4);
27299 else r /= 12.92;
27300 if (g > 0.04045) g = pow(((g + 0.055) / 1.055), 2.4);
27301 else g /= 12.92;
27302 if (b > 0.04045) b = pow(((b + 0.055) / 1.055), 2.4);
27303 else b /= 12.92;
27304
27305 double x = r * 0.4124 + g * 0.3576 + b * 0.1805;
27306 double y = r * 0.2126 + g * 0.7152 + b * 0.0722;
27307 double z = r * 0.0193 + g * 0.1192 + b * 0.9505;
27308
27309 if (x > 0.008856) x = pow(x, 1.0 / 3.0);
27310 else x = (7.787 * x) + (16.0 / 116.0);
27311 if (y > 0.008856) y = pow(y, 1.0 / 3.0);
27312 else y = (7.787 * y) + (16.0 / 116.0);
27313 if (z > 0.008856) z = pow(z, 1.0 / 3.0);
27314 else z = (7.787 * z) + (16.0 / 116.0);
27315
27316 double CIEL = (116 * y) - 16;
27317 double CIEa = 500 * (x - y);
27318 double CIEb = 200 * (y - z);
27319
27320 arr[0] = CIEL;
27321 arr[1] = CIEa;
27322 arr[2] = CIEb;
27323 break;
27324 }
27325 case CSPACE_LCH_CW:
27326 case CSPACE_LCH_CCW:
27327 case CSPACE_LCH:
27328 {
27329 if (r > 0.04045) r = pow(((r + 0.055) / 1.055), 2.4);
27330 else r /= 12.92;
27331 if (g > 0.04045) g = pow(((g + 0.055) / 1.055), 2.4);
27332 else g /= 12.92;
27333 if (b > 0.04045) b = pow(((b + 0.055) / 1.055), 2.4);
27334 else b /= 12.92;
27335
27336 double x = r * 0.4124 + g * 0.3576 + b * 0.1805;
27337 double y = r * 0.2126 + g * 0.7152 + b * 0.0722;
27338 double z = r * 0.0193 + g * 0.1192 + b * 0.9505;
27339
27340 if (x > 0.008856) x = pow(x, 1.0 / 3.0);
27341 else x = (7.787 * x) + (16.0 / 116.0);
27342 if (y > 0.008856) y = pow(y, 1.0 / 3.0);
27343 else y = (7.787 * y) + (16.0 / 116.0);
27344 if (z > 0.008856) z = pow(z, 1.0 / 3.0);
27345 else z = (7.787 * z) + (16.0 / 116.0);
27346
27347 double CIEL = (116 * y) - 16;
27348 double CIEa = 500 * (x - y);
27349 double CIEb = 200 * (y - z);
27350
27351 double h = atan2(CIEb, CIEa);
27352 if (h > 0) h = (h / PI) * 180;
27353 else h = 360 - (abs(h) / PI) * 180;
27354
27355 double CIEC = sqrt(pow(CIEa, 2) + pow(CIEb, 2));
27356
27357 arr[0] = CIEL;
27358 arr[1] = CIEC;
27359 arr[2] = h;
27360 break;
27361 }
27362 }
27363
27364 }
27365
27366 RGB user_paldata::RGBFrom(double arr[], int32_t color_space)
27367 {
27368 double r = 0.0;
27369 double g = 0.0;
27370 double b = 0.0;
27371 switch (color_space)
27372 {
27373 case CSPACE_CMYK:
27374 {
27375 double c = (arr[0] * (1 - arr[3]) + arr[3]);
27376 double m = (arr[1] * (1 - arr[3]) + arr[3]);
27377 double y = (arr[2] * (1 - arr[3]) + arr[3]);
27378
27379 r = vbound((1 - c) * 63.0, 0.0, 63.0);
27380 g = vbound((1 - m) * 63.0, 0.0, 63.0);
27381 b = vbound((1 - y) * 63.0, 0.0, 63.0);
27382 return _RGB(r, g, b);
27383 break;
27384 }
27385 case CSPACE_HSV_CW:
27386 case CSPACE_HSV_CCW:
27387 case CSPACE_HSV:
27388 {
27389 double h = arr[0];
27390 double s = arr[1];
27391 double v = arr[2];
27392
27393 if (s == 0)
27394 {
27395 r = v;
27396 g = v;
27397 b = v;
27398 }
27399 else
27400 {
27401 double var_h = h * 6;
27402 if (var_h >= 6) var_h = 0;
27403 int32_t var_i = floor(var_h);
27404 double var_1 = v * (1 - s);
27405 double var_2 = v * (1 - s * (var_h - var_i));
27406 double var_3 = v * (1 - s * (1 - (var_h - var_i)));
27407
27408 switch (var_i)
27409 {
27410 case 0:
27411 r = v;
27412 g = var_3;
27413 b = var_1;
27414 break;
27415 case 1:
27416 r = var_2;
27417 g = v;
27418 b = var_1;
27419 break;
27420 case 2:
27421 r = var_1;
27422 g = v;
27423 b = var_3;
27424 break;
27425 case 3:
27426 r = var_1;
27427 g = var_2;
27428 b = v;
27429 break;
27430 case 4:
27431 r = var_3;
27432 g = var_1;
27433 b = v;
27434 break;
27435 default:
27436 r = v;
27437 g = var_1;
27438 b = var_2;
27439 }
27440 }
27441
27442 r = vbound(r * 63.0, 0.0, 63.0);
27443 g = vbound(g * 63.0, 0.0, 63.0);
27444 b = vbound(b * 63.0, 0.0, 63.0);
27445
27446 return _RGB(r, g, b);
27447 }
27448 case CSPACE_HSL_CW:
27449 case CSPACE_HSL_CCW:
27450 case CSPACE_HSL:
27451 {
27452 double h = arr[0];
27453 double s = arr[1];
27454 double l = arr[2];
27455
27456 if (s == 0)
27457 {
27458 r = l;
27459 g = l;
27460 b = l;
27461 }
27462 else
27463 {
27464 double var_1;
27465 double var_2;
27466 if (l < 0.5)var_2 = l * (1 + s);
27467 else var_2 = (l + s) - (s * l);
27468
27469 var_1 = 2 * l - var_2;
27470
27471 r = HueToRGB(var_1, var_2, h + (1.0 / 3.0));
27472 g = HueToRGB(var_1, var_2, h);
27473 b = HueToRGB(var_1, var_2, h - (1.0 / 3.0));
27474 }
27475
27476 r = vbound(r * 63.0, 0.0, 63.0);
27477 g = vbound(g * 63.0, 0.0, 63.0);
27478 b = vbound(b * 63.0, 0.0, 63.0);
27479
27480 return _RGB(r, g, b);
27481 }
27482 case CSPACE_LAB:
27483 {
27484 double CIEL = arr[0];
27485 double CIEa = arr[1];
27486 double CIEb = arr[2];
27487
27488 double var_y = (CIEL + 16) / 116.0;
27489 double var_x = CIEa / 500.0 + var_y;
27490 double var_z = var_y - CIEb / 200.0;
27491
27492 if (pow(var_x, 3) > 0.008856) var_x = pow(var_x, 3);
27493 else var_x = (var_x - 16.0 / 116.0) / 7.787;
27494 if (pow(var_y, 3) > 0.008856) var_y = pow(var_y, 3);
27495 else var_y = (var_y - 16.0 / 116.0) / 7.787;
27496 if (pow(var_z, 3) > 0.008856) var_z = pow(var_z, 3);
27497 else var_z = (var_z - 16.0 / 116.0) / 7.787;
27498
27499 r = var_x * 3.2406 + var_y * -1.5372 + var_z * -0.4986;
27500 g = var_x * -0.9689 + var_y * 1.8758 + var_z * 0.0415;
27501 b = var_x * 0.0557 + var_y * -0.2040 + var_z * 1.0570;
27502
27503 if (r > 0.0031308) r = 1.055 * pow(r, (1 / 2.4)) - 0.055;
27504 else r = 12.92 * r;
27505 if (g > 0.0031308) g = 1.055 * pow(g, (1 / 2.4)) - 0.055;
27506 else g = 12.92 * g;
27507 if (b > 0.0031308) b = 1.055 * pow(b, (1 / 2.4)) - 0.055;
27508 else b = 12.92 * b;
27509
27510 r = vbound(r * 63.0, 0.0, 63.0);
27511 g = vbound(g * 63.0, 0.0, 63.0);
27512 b = vbound(b * 63.0, 0.0, 63.0);
27513
27514 return _RGB(r, g, b);
27515 }
27516 case CSPACE_LCH_CW:
27517 case CSPACE_LCH_CCW:
27518 case CSPACE_LCH:
27519 {
27520 double CIEL = arr[0];
27521 double CIEa = cos((arr[2] * PI) / 180.0) * arr[1];
27522 double CIEb = sin((arr[2] * PI) / 180.0) * arr[1];
27523
27524 double var_y = (CIEL + 16) / 116.0;
27525 double var_x = CIEa / 500.0 + var_y;
27526 double var_z = var_y - CIEb / 200.0;
27527
27528 if (pow(var_y, 3) > 0.008856) var_y = pow(var_y, 3);
27529 else var_y = (var_y - 16.0 / 116.0) / 7.787;
27530 if (pow(var_x, 3) > 0.008856) var_x = pow(var_x, 3);
27531 else var_x = (var_x - 16.0 / 116.0) / 7.787;
27532 if (pow(var_z, 3) > 0.008856) var_z = pow(var_z, 3);
27533 else var_z = (var_z - 16.0 / 116.0) / 7.787;
27534
27535 r = var_x * 3.2406 + var_y * -1.5372 + var_z * -0.4986;
27536 g = var_x * -0.9689 + var_y * 1.8758 + var_z * 0.0415;
27537 b = var_x * 0.0557 + var_y * -0.2040 + var_z * 1.0570;
27538
27539 if (r > 0.0031308) r = 1.055 * pow(r, (1 / 2.4)) - 0.055;
27540 else r = 12.92 * r;
27541 if (g > 0.0031308) g = 1.055 * pow(g, (1 / 2.4)) - 0.055;
27542 else g = 12.92 * g;
27543 if (b > 0.0031308) b = 1.055 * pow(b, (1 / 2.4)) - 0.055;
27544 else b = 12.92 * b;
27545
27546 r = vbound(r * 63.0, 0.0, 63.0);
27547 g = vbound(g * 63.0, 0.0, 63.0);
27548 b = vbound(b * 63.0, 0.0, 63.0);
27549
27550 return _RGB(r, g, b);
27551 }
27552 }
27553 return _RGB(0, 0, 0);
27554 }
27555 double user_paldata::HueToRGB(double v1, double v2, double vH)
27556 {
27557 if (vH < 0) vH += 1;
27558 if (vH > 1) vH -= 1;
27559 if ((6 * vH) < 1) return (v1 + (v2 - v1) * 6 * vH);
27560 if ((2 * vH) < 1) return (v2);
27561 if ((3 * vH) < 2) return (v1 + (v2 - v1) * ((2.0 / 3.0) - vH) * 6);
27562 return (v1);
27563 }
27564
27565 double user_paldata::WrapLerp(double a, double b, double t, double min, double max, int32_t direction)
27566 {
27567 double dif = abs(a - b);
27568 double range = abs(max - min);
27569
27570 switch (direction)
27571 {
27572 case 0:
27573 if (dif > range * 0.5)
27574 dif = range - dif;
27575 if (a + dif == b)
27576 direction = 1;
27577 else
27578 direction = -1;
27579 break;
27580 case 1:
27581 if (b < a)
27582 dif = range - dif;
27583 break;
27584 case -1:
27585 if (b > a)
27586 dif = range - dif;
27587 break;
27588 }
27589
27590 double ret = zc::math::Lerp(a, a + dif * direction, t);
27591
27592 if (ret <= min)
27593 ret += range;
27594 else if (ret >= max)
27595 ret -= range;
27596 return ret;
27597 }
27598
27599 //Mixes an entire palette given two paldatas
27600 void user_paldata::mix(user_paldata *pal_start, user_paldata *pal_end, double percent, int32_t color_space, int32_t start_color, int32_t end_color)
27601 {
27602 for (int32_t q = start_color; q < end_color; ++q)
27603 {
27604 if (get_bit(pal_start->colors_used, q) && get_bit(pal_end->colors_used, q)) {
27605 RGB start = pal_start->colors[q];
27606 RGB end = pal_end->colors[q];
27607 colors[q] = mix_color(start, end, percent, color_space);
27608 }
27609 }
27610 }
27611
27612 void item_display_name(const bool setter)
27613 {
27614 int32_t ID = ri->idata;
27615 if(unsigned(ID) >= MAXITEMS)
27616 return;
27617 int32_t arrayptr = get_register(sarg1) / 10000;
27618 if(setter)
27619 {
27620 std::string str;
27621 ArrayH::getString(arrayptr, str, 255);
27622 strcpy(itemsbuf[ID].display_name, str.c_str());
27623 }
27624 else
27625 {
27626 if(ArrayH::setArray(arrayptr, string(itemsbuf[ID].display_name)) == SH::_Overflow)
27627 Z_scripterrlog("Array supplied to 'itemdata->GetDisplayName()' not large enough\n");
27628 }
27629 }
27630 void item_shown_name()
27631 {
27632 int32_t ID = ri->idata;
27633 if(unsigned(ID) >= MAXITEMS)
27634 return;
27635 int32_t arrayptr = get_register(sarg1) / 10000;
27636 if(ArrayH::setArray(arrayptr, itemsbuf[ID].get_name()) == SH::_Overflow)
27637 Z_scripterrlog("Array supplied to 'itemdata->GetShownName()' not large enough\n");
27638 }
27639
27640 void FFScript::do_getDMapData_dmapname(const bool v)
27641 {
27642 //int32_t ID = ri->zmsgref;
27643 int32_t ID = ri->dmapsref;
27644 int32_t arrayptr = get_register(sarg1) / 10000;
27645
27646 if(BC::checkDMapID(ID, "dmapdata->GetName()") != SH::_NoError)
27647 return;
27648
27649 if(ArrayH::setArray(arrayptr, string(DMaps[ID].name)) == SH::_Overflow)
27650 Z_scripterrlog("Array supplied to 'dmapdata->GetName()' not large enough\n");
27651 }
27652
27653 void FFScript::do_setDMapData_dmapname(const bool v)
27654 {
27655 //int32_t ID = ri->zmsgref;
27656 int32_t ID = ri->dmapsref;
27657 int32_t arrayptr = get_register(sarg1) / 10000;
27658
27659 string filename_str;
27660
27661 if(BC::checkDMapID(ID, "dmapdata->SetName()") != SH::_NoError)
27662 return;
27663
27664
27665 ArrayH::getString(arrayptr, filename_str, 22);
27666 strncpy(DMaps[ID].name, filename_str.c_str(), 21);
27667 DMaps[ID].name[20]='\0';
27668 }
27669
27670 void FFScript::do_getDMapData_dmaptitle(const bool v)
27671 {
27672 //int32_t ID = ri->zmsgref;
27673 int32_t ID = ri->dmapsref;
27674 int32_t arrayptr = get_register(sarg1) / 10000;
27675
27676 if(BC::checkDMapID(ID, "dmapdata->GetIntro()") != SH::_NoError)
27677 return;
27678
27679 if(ArrayH::setArray(arrayptr, string(DMaps[ID].title)) == SH::_Overflow)
27680 Z_scripterrlog("Array supplied to 'dmapdata->GetIntro()' not large enough\n");
27681 }
27682
27683 void FFScript::do_setDMapData_dmaptitle(const bool v)
27684 {
27685 //int32_t ID = ri->zmsgref;
27686 int32_t ID = ri->dmapsref;
27687 int32_t arrayptr = get_register(sarg1) / 10000;
27688 string filename_str;
27689
27690 if(BC::checkDMapID(ID, "dmapdata->SetTitle()") != SH::_NoError)
27691 return;
27692
27693
27694 ArrayH::getString(arrayptr, filename_str, 21);
27695 strncpy(DMaps[ID].title, filename_str.c_str(), 20);
27696 DMaps[ID].title[20]='\0';
27697 }
27698
27699 void FFScript::do_getDMapData_dmapintro(const bool v)
27700 {
27701 //int32_t ID = ri->zmsgref;
27702 int32_t ID = ri->dmapsref;
27703 int32_t arrayptr = get_register(sarg1) / 10000;
27704
27705 if(BC::checkDMapID(ID, "dmapdata->GetIntro()") != SH::_NoError)
27706 return;
27707
27708 if(ArrayH::setArray(arrayptr, string(DMaps[ID].intro)) == SH::_Overflow)
27709 Z_scripterrlog("Array supplied to 'dmapdata->GetIntro()' not large enough\n");
27710 }
27711
27712 void FFScript::do_setDMapData_dmapintro(const bool v)
27713 {
27714 //int32_t ID = ri->zmsgref;
27715 int32_t ID = ri->dmapsref;
27716 int32_t arrayptr = get_register(sarg1) / 10000;
27717 string filename_str;
27718
27719 if(BC::checkDMapID(ID, "dmapdata->SetIntro()") != SH::_NoError)
27720 return;
27721
27722
27723 ArrayH::getString(arrayptr, filename_str, 73);
27724 strncpy(DMaps[ID].intro, filename_str.c_str(), 72);
27725 DMaps[ID].intro[72]='\0';
27726 }
27727
27728 void FFScript::do_getDMapData_music(const bool v)
27729 {
27730 //int32_t ID = ri->zmsgref;
27731 int32_t ID = ri->dmapsref;
27732 int32_t arrayptr = get_register(sarg1) / 10000;
27733
27734 if(BC::checkDMapID(ID, "dmapdata->GetMusic()") != SH::_NoError)
27735 return;
27736
27737 if(ArrayH::setArray(arrayptr, string(DMaps[ID].tmusic)) == SH::_Overflow)
27738 Z_scripterrlog("Array supplied to 'dmapdata->GetMusic()' not large enough\n");
27739 }
27740
27741 void FFScript::do_setDMapData_music(const bool v)
27742 {
27743 //int32_t ID = ri->zmsgref;
27744 int32_t ID = ri->dmapsref;
27745 int32_t arrayptr = get_register(sarg1) / 10000;
27746 string filename_str;
27747
27748 if(BC::checkDMapID(ID, "dmapdata->SetMusic()") != SH::_NoError)
27749 return;
27750
27751
27752 ArrayH::getString(arrayptr, filename_str, 56);
27753 strncpy(DMaps[ID].tmusic, filename_str.c_str(), 55);
27754 DMaps[ID].tmusic[55]='\0';
27755 }
27756
27757 void FFScript::do_loadnpcdata(const bool v)
27758 {
27759 int32_t ID = SH::get_arg(sarg1, v) / 10000;
27760
27761 if ( ID < 1 || ID > (MAXGUYS-1) )
27762 {
27763 Z_scripterrlog("Invalid NPC ID passed to Game->LoadNPCData: %d\n", ID);
27764 ri->npcdataref = MAX_DWORD;
27765 }
27766
27767 else ri->npcdataref = ID;
27768 //Z_eventlog("Script loaded npcdata with ID = %ld\n", ri->idata);
27769 }
27770 void FFScript::do_loadmessagedata(const bool v)
27771 {
27772 int32_t ID = SH::get_arg(sarg1, v) / 10000;
27773
27774 if ( ID < 1 || ID > (msg_count-1) )
27775 {
27776 Z_scripterrlog("Invalid Message ID passed to Game->LoadMessageData: %d\n", ID);
27777 ri->zmsgref = MAX_DWORD;
27778 }
27779
27780 else ri->zmsgref = ID;
27781 //Z_eventlog("Script loaded npcdata with ID = %ld\n", ri->idata);
27782 }
27783 //same syntax as loadmessage data
27784 //the input is an array
27785 void FFScript::do_messagedata_setstring(const bool v)
27786 {
27787 int32_t arrayptr = get_register(sarg1) / 10000;
27788 int32_t ID = ri->zmsgref;
27789 if(BC::checkMessage(ID, "messagesata->Set()") != SH::_NoError)
27790 return;
27791
27792 ArrayH::getString(arrayptr, MsgStrings[ID].s, MSG_NEW_SIZE);
27793 }
27794 void FFScript::do_messagedata_getstring(const bool v)
27795 {
27796 int32_t ID = ri->zmsgref;
27797 int32_t arrayptr = get_register(sarg1) / 10000;
27798
27799 if(BC::checkMessage(ID, "messagedata->Get()") != SH::_NoError)
27800 return;
27801
27802 if(ArrayH::setArray(arrayptr, MsgStrings[ID].s) == SH::_Overflow)
27803 Z_scripterrlog("Array supplied to 'messagedata->Get()' not large enough\n");
27804 }
27805
27806 25412 void FFScript::do_loadcombodata(const bool v)
27807 {
27808 25412 int32_t ID = SH::get_arg(sarg1, v) / 10000;
27809
27810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25412 times.
25412 if ( (unsigned)ID > (MAXCOMBOS-1) )
27811 {
27812 Z_scripterrlog("Invalid Combo ID passed to Game->LoadComboData: %d\n", ID);
27813 ri->combosref = 0;
27814 }
27815
27816 25412 else ri->combosref = ID;
27817 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
27818 25412 }
27819
27820 void FFScript::do_loadmapdata(const bool v)
27821 {
27822 int32_t _map = SH::get_arg(sarg1, v) / 10000;
27823
27824 int32_t _scr = SH::get_arg(sarg2, v) / 10000;
27825 // zprint("LoadMapData Map Value: %d\n", _map);
27826 // zprint("LoadMapData Screen Value: %d\n", _scr);
27827 int32_t indx = (_map * MAPSCRS + _scr);
27828 // zprint("LoadMapData Indx Value: %d\n", indx);
27829 if ( _map < 1 || _map > (map_count-1) )
27830 {
27831 Z_scripterrlog("Invalid Map ID passed to Game->LoadMapData: %d\n", _map);
27832 ri->mapsref = 0;
27833 }
27834 else if ( (unsigned)_scr > 129 ) //0x00 to 0x81 -Z
27835 {
27836 Z_scripterrlog("Invalid Screen ID passed to Game->LoadMapData: %d\n", _scr);
27837 ri->mapsref = 0;
27838 }
27839 else ri->mapsref = indx;
27840 // zprint("LoadMapData Screen set ri->mapsref to: %d\n", ri->mapsref);
27841 //zprint("Script loaded mapdata with ID = %ld\n", ri->idata);
27842 }
27843
27844 403560 void FFScript::do_loadmapdata_tempscr(const bool v)
27845 {
27846 403560 int32_t layer = SH::get_arg(sarg1, v) / 10000;
27847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 403560 times.
403560 if(BC::checkBounds(layer, 0, 6, "Game->LoadTempScreen()") != SH::_NoError)
27848 {
27849 ri->mapsref = 0;
27850 return;
27851 }
27852
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 89786 times.
✓ Branch 2 taken 118175 times.
✓ Branch 3 taken 103000 times.
✓ Branch 4 taken 915 times.
✓ Branch 5 taken 91682 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
403560 switch(layer)
27853 {
27854 89786 case 0: ri->mapsref = MAPSCR_TEMP0; break;
27855 118175 case 1: ri->mapsref = MAPSCR_TEMP1; break;
27856 103000 case 2: ri->mapsref = MAPSCR_TEMP2; break;
27857 915 case 3: ri->mapsref = MAPSCR_TEMP3; break;
27858 91682 case 4: ri->mapsref = MAPSCR_TEMP4; break;
27859 1 case 5: ri->mapsref = MAPSCR_TEMP5; break;
27860 1 case 6: ri->mapsref = MAPSCR_TEMP6; break;
27861 }
27862 403560 set_register(sarg1, ri->mapsref);
27863 403560 }
27864
27865 177544 void FFScript::do_loadmapdata_scrollscr(const bool v)
27866 {
27867 177544 int32_t layer = SH::get_arg(sarg1, v) / 10000;
27868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177544 times.
177544 if(BC::checkBounds(layer, 0, 6, "Game->LoadScrollingScreen()") != SH::_NoError)
27869 {
27870 ri->mapsref = 0;
27871 return;
27872 }
27873
3/8
✗ Branch 0 not taken.
✓ Branch 1 taken 88755 times.
✓ Branch 2 taken 88755 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 34 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
177544 switch(layer)
27874 {
27875 88755 case 0: ri->mapsref = MAPSCR_SCROLL0; break;
27876 88755 case 1: ri->mapsref = MAPSCR_SCROLL1; break;
27877 case 2: ri->mapsref = MAPSCR_SCROLL2; break;
27878 case 3: ri->mapsref = MAPSCR_SCROLL3; break;
27879 34 case 4: ri->mapsref = MAPSCR_SCROLL4; break;
27880 case 5: ri->mapsref = MAPSCR_SCROLL5; break;
27881 case 6: ri->mapsref = MAPSCR_SCROLL6; break;
27882 }
27883 177544 set_register(sarg1, ri->mapsref);
27884 177544 }
27885
27886 void FFScript::do_loadshopdata(const bool v)
27887 {
27888 int32_t ID = SH::get_arg(sarg1, v) / 10000;
27889
27890 if ( (unsigned)ID > 255 )
27891 {
27892 Z_scripterrlog("Invalid Shop ID passed to Game->LoadShopData: %d\n", ID);
27893 ri->shopsref = 0;
27894 }
27895 else ri->shopsref = ID;
27896 //Z_eventlog("Script loaded npcdata with ID = %ld\n", ri->idata);
27897 }
27898
27899
27900 void FFScript::do_loadinfoshopdata(const bool v)
27901 {
27902 int32_t ID = SH::get_arg(sarg1, v) / 10000;
27903
27904 if ( (unsigned)ID > 255 )
27905 {
27906 Z_scripterrlog("Invalid Shop ID passed to Game->LoadShopData: %d\n", ID);
27907 ri->shopsref = 0;
27908 }
27909 else ri->shopsref = ID+NUMSHOPS;
27910 //Z_eventlog("Script loaded npcdata with ID = %ld\n", ri->idata);
27911 }
27912
27913 /*
27914 void FFScript::do_loadmapdata(const bool v)
27915 {
27916 int32_t ID = SH::get_arg(sarg1, v) / 10000;
27917
27918 if ( ID < 0 || ID > (map_count-1) )
27919 {
27920 Z_scripterrlog("Invalid Map ID passed to Game->LoadMapData: %d\n", ID);
27921 ri->mapsref = MAX_SIGNED_32;
27922 }
27923
27924 else ri->mapsref = ID;
27925 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
27926 }
27927 */
27928
27929 /*
27930
27931 void FFScript::do_loadmapdata(const bool v)
27932 {
27933 int32_t ID = get_register(sarg2) / 10000;
27934
27935 if ( ID < 0 || ID > (map_count-1) )
27936 {
27937 Z_scripterrlog("Invalid Map ID passed to Game->LoadMapData: %d\n", ID);
27938 return;
27939 }
27940
27941 ri->mapsref = ID;
27942 set_register(sarg1, ri->mapsref);
27943 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
27944 }
27945
27946 */
27947
27948 16 void FFScript::do_loadspritedata(const bool v)
27949 {
27950 16 int32_t ID = SH::get_arg(sarg1, v) / 10000;
27951
27952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( (unsigned)ID > (MAXWPNS-1) )
27953 {
27954 Z_scripterrlog("Invalid Sprite ID passed to Game->LoadSpriteData: %d\n", ID);
27955 ri->spritesref = 0;
27956 }
27957
27958 16 else ri->spritesref = ID;
27959 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
27960 16 }
27961
27962
27963 void FFScript::do_loadscreendata(const bool v)
27964 {
27965 int32_t ID = SH::get_arg(sarg1, v) / 10000;
27966
27967 if ( (unsigned)ID > (MAXSCREENS-1) )
27968 {
27969 Z_scripterrlog("Invalid Map ID passed to Game->LoadScreenData: %d\n", ID);
27970 ri->screenref = 0;
27971 }
27972
27973 else ri->screenref = ID;
27974 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
27975 }
27976
27977 void FFScript::do_loadbitmapid(const bool v)
27978 {
27979 int32_t ID = SH::get_arg(sarg1, v) / 10000;
27980 switch(ID)
27981 {
27982 case -1:
27983 case 0:
27984 case 1:
27985 case 2:
27986 case 3:
27987 case 4:
27988 case 5:
27989 case 6:
27990 ri->bitmapref = ID+10; break;
27991 default:
27992 {
27993 Z_scripterrlog("Invalid Bitmap ID passed to Game->Load BitmapID: %d\n", ID);
27994 ri->bitmapref = 0; break;
27995 }
27996 }
27997
27998 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
27999 }
28000
28001 77278 void do_createlweapon(const bool v)
28002 {
28003 77278 const int32_t ID = SH::get_arg(sarg1, v) / 10000;
28004
28005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77278 times.
77278 if(BC::checkWeaponID(ID, "Screen->CreateLWeapon") != SH::_NoError)
28006 return;
28007
28008
1/2
✓ Branch 0 taken 77278 times.
✗ Branch 1 not taken.
77278 if ( Lwpns.has_space() )
28009 {
28010 77278 Lwpns.add
28011 (
28012
1/2
✓ Branch 0 taken 77278 times.
✗ Branch 1 not taken.
154556 new weapon
28013 (
28014
1/2
✓ Branch 0 taken 77278 times.
✗ Branch 1 not taken.
77278 (zfix)0, /*X*/
28015
1/2
✓ Branch 0 taken 77278 times.
✗ Branch 1 not taken.
77278 (zfix)0, /*Y*/
28016
1/2
✓ Branch 0 taken 77278 times.
✗ Branch 1 not taken.
77278 (zfix)0, /*Z*/
28017 77278 ID, /*id*/
28018 0, /*type*/
28019 0, /*power*/
28020 0, /*dir*/
28021 -1, /*Parentid*/
28022
1/2
✓ Branch 0 taken 77278 times.
✗ Branch 1 not taken.
77278 Hero.getUID(), /*prntid*/
28023 false, /*isdummy*/
28024 1, /*script_gen*/
28025 1, /*islwpn*/
28026 77278 (ID==wWind?1:0) /*special*/
28027 )
28028 );
28029 77278 ri->lwpn = Lwpns.spr(Lwpns.Count() - 1)->getUID();
28030 //Lwpns.spr(Lwpns.Count() - 1)->LOADGFX(0);
28031 //Lwpns.spr(Lwpns.Count() - 1)->ScriptGenerated = 1;
28032 //Lwpns.spr(Lwpns.Count() - 1)->isLWeapon = 1;
28033 77278 weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //last created
28034 //w->LOADGFX(FFCore.getDefWeaponSprite(ID)); //No.
28035 77278 w->ScriptGenerated = 1;
28036 77278 w->isLWeapon = 1;
28037
1/2
✓ Branch 0 taken 77278 times.
✗ Branch 1 not taken.
77278 if(ID == wWind) w->specialinfo = 1;
28038 77278 Z_eventlog("Script created lweapon %ld with UID = %ld\n", ID, ri->lwpn);
28039 77278 }
28040 else
28041 {
28042 //ri->lwpn = MAX_DWORD;
28043 ri->lwpn = 0; // Now NULL
28044 Z_scripterrlog("Couldn't create lweapon %ld, screen lweapon limit reached\n", ID);
28045 }
28046 77278 }
28047
28048 131917 void do_createeweapon(const bool v)
28049 {
28050 131917 const int32_t ID = SH::get_arg(sarg1, v) / 10000;
28051
28052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131917 times.
131917 if(BC::checkWeaponID(ID, "Screen->CreateEWeapon") != SH::_NoError)
28053 return;
28054
28055
1/2
✓ Branch 0 taken 131917 times.
✗ Branch 1 not taken.
131917 if ( Ewpns.has_space() )
28056 {
28057 131917 addEwpn(0, 0, 0, ID, 0, 0, 0, -1,1); //Param 9 marks it as script-generated.
28058 //Ewpns.spr(Ewpns.Count() - 1)->LOADGFX(0);
28059 //Ewpns.spr(Ewpns.Count() - 1)->ScriptGenerated = 1;
28060 //Ewpns.spr(Ewpns.Count() - 1)->isLWeapon = 0;
28061
4/6
✓ Branch 0 taken 122104 times.
✓ Branch 1 taken 9813 times.
✓ Branch 2 taken 122104 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 122104 times.
✗ Branch 5 not taken.
131917 if( ID > wEnemyWeapons || ( ID >= wScript1 && ID <= wScript10) )
28062 {
28063 131917 weapon *w = (weapon*)Ewpns.spr(Ewpns.Count()-1); //last created
28064 //w->LOADGFX(FFCore.getDefWeaponSprite(ID));
28065 131917 w->ScriptGenerated = 1;
28066 131917 w->isLWeapon = 0;
28067 131917 ri->ewpn = Ewpns.spr(Ewpns.Count() - 1)->getUID();
28068 131917 Z_eventlog("Script created eweapon %ld with UID = %ld\n", ID, ri->ewpn);
28069 131917 }
28070 else
28071 {
28072 Z_scripterrlog("Couldn't create eweapon %ld: Invalid ID/Type (%d) specified.\n", ID);
28073 return;
28074 }
28075 131917 }
28076 else
28077 {
28078 ri->ewpn = 0;
28079 Z_scripterrlog("Couldn't create eweapon %ld, screen eweapon limit reached\n", ID);
28080 }
28081 131917 }
28082
28083 21343 void do_createitem(const bool v)
28084 {
28085 21343 const int32_t ID = SH::get_arg(sarg1, v) / 10000;
28086
28087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21343 times.
21343 if(BC::checkItemID(ID, "Screen->CreateItem") != SH::_NoError)
28088 return;
28089
28090
1/2
✓ Branch 0 taken 21343 times.
✗ Branch 1 not taken.
21343 if ( items.has_space() )
28091 {
28092 21343 additem(0, (get_qr(qr_NOITEMOFFSET) ? 1: 0), ID, ipBIGRANGE);
28093 21343 ri->itemref = items.spr(items.Count() - 1)->getUID();
28094 21343 Z_eventlog("Script created item \"%s\" with UID = %ld\n", item_string[ID], ri->itemref);
28095 21343 }
28096 else
28097 {
28098 ri->itemref = 0;
28099 Z_scripterrlog("Couldn't create item \"%s\", screen item limit reached\n", item_string[ID]);
28100 }
28101 /*
28102 if(items.Count() < 1)
28103 {
28104 ri->itemref = MAX_DWORD;
28105 Z_scripterrlog("Couldn't create item \"%s\", screen item limit reached\n", item_string[ID]);
28106 }
28107 else
28108 {
28109 ri->itemref = items.spr(items.Count() - 1)->getUID();
28110 Z_eventlog("Script created item \"%s\" with UID = %ld\n", item_string[ID], ri->itemref);
28111 }
28112 */
28113 21343 }
28114
28115 2363 void do_createnpc(const bool v)
28116 {
28117 2363 const int32_t ID = SH::get_arg(sarg1, v) / 10000;
28118
28119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2363 times.
2363 if(BC::checkGuyID(ID, "Screen->CreateNPC") != SH::_NoError)
28120 return;
28121
28122 //If we make a segmented enemy there'll be more than one sprite created
28123 2363 word numcreated = addenemy(0, 0, ID, -10);
28124
28125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2363 times.
2363 if(numcreated == 0)
28126 {
28127 //ri->guyref = MAX_DWORD;
28128 ri->guyref = 0;
28129 Z_scripterrlog("Couldn't create NPC \"%s\", screen NPC limit reached\n", guy_string[ID]);
28130 }
28131 else
28132 {
28133 2363 word index = guys.Count() - numcreated; //Get the main enemy, not a segment
28134 2363 ri->guyref = guys.spr(index)->getUID();
28135
28136
2/2
✓ Branch 0 taken 2399 times.
✓ Branch 1 taken 2363 times.
4762 for(; index<guys.Count(); index++)
28137 2399 ((enemy*)guys.spr(index))->script_spawned=true;
28138
28139 2363 Z_eventlog("Script created NPC \"%s\" with UID = %ld\n", guy_string[ID], ri->guyref);
28140 }
28141 2363 }
28142
28143 ///----------------------------------------------------------------------------------------------------//
28144 //Drawing & Sound
28145
28146 173 void do_message(const bool v)
28147 {
28148 173 const int32_t ID = SH::get_arg(sarg1, v) / 10000;
28149
28150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 173 times.
173 if(BC::checkMessage(ID, "Screen->Message") != SH::_NoError)
28151 return;
28152
28153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 173 times.
173 if(ID == 0)
28154 {
28155 dismissmsg();
28156 msgfont = get_zc_font(font_zfont);
28157 blockpath = false;
28158 Hero.finishedmsg();
28159 }
28160 else
28161 173 donewmsg(ID);
28162 173 }
28163
28164 37316241 INLINE void set_drawing_command_args(const int32_t j, const word numargs)
28165 {
28166
2/2
✓ Branch 0 taken 294454951 times.
✓ Branch 1 taken 37316241 times.
331771192 for(int32_t k = 1; k <= numargs; k++)
28167 294454951 script_drawing_commands[j][k] = SH::read_stack(ri->sp + (numargs - k));
28168 37316241 }
28169
28170 661825 INLINE void set_user_bitmap_command_args(const int32_t j, const word numargs)
28171 {
28172 //ri->bitmapref = SH::read_stack(ri->sp+numargs);
28173 //zprint("Current drawing bitmap ref is: %d\n", ri->bitmapref );
28174
2/2
✓ Branch 0 taken 7096930 times.
✓ Branch 1 taken 661825 times.
7758755 for(int32_t k = 1; k <= numargs; k++)
28175 7096930 script_drawing_commands[j][k] = SH::read_stack(ri->sp + (numargs - k));
28176 661825 }
28177
28178 37978066 void do_drawing_command(const int32_t script_command)
28179 {
28180 37978066 int32_t j = script_drawing_commands.GetNext();
28181
28182
1/2
✓ Branch 0 taken 37978066 times.
✗ Branch 1 not taken.
37978066 if(j == -1) //out of drawing command space
28183 {
28184 Z_scripterrlog("Max draw primitive limit reached\n");
28185 return;
28186 }
28187
28188 37978066 script_drawing_commands[j][0] = script_command;
28189 37978066 script_drawing_commands[j][18] = zscriptDrawingRenderTarget->GetCurrentRenderTarget(); // no fixed bs.
28190
28191
36/76
✓ Branch 0 taken 2223630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1056651 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1850 times.
✓ Branch 5 taken 937398 times.
✓ Branch 6 taken 383247 times.
✓ Branch 7 taken 828501 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1716768 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4759287 times.
✓ Branch 12 taken 17998198 times.
✓ Branch 13 taken 936091 times.
✓ Branch 14 taken 94003 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 9270 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 802244 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 49303 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 1240874 times.
✓ Branch 24 taken 150650 times.
✓ Branch 25 taken 7818 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 23013 times.
✓ Branch 28 taken 2790 times.
✓ Branch 29 taken 26528 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 1480 times.
✗ Branch 32 not taken.
✓ Branch 33 taken 502 times.
✓ Branch 34 taken 144 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 80910 times.
✗ Branch 37 not taken.
✓ Branch 38 taken 824 times.
✗ Branch 39 not taken.
✓ Branch 40 taken 166191 times.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✓ Branch 46 taken 1173 times.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✓ Branch 55 taken 2051 times.
✗ Branch 56 not taken.
✓ Branch 57 taken 6363 times.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✓ Branch 64 taken 4128276 times.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✓ Branch 67 taken 59173 times.
✓ Branch 68 taken 784 times.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✓ Branch 71 taken 45504 times.
✗ Branch 72 not taken.
✓ Branch 73 taken 234762 times.
✓ Branch 74 taken 909 times.
✓ Branch 75 taken 906 times.
37978066 switch(script_command)
28192 {
28193 case RECTR:
28194 2223630 set_drawing_command_args(j, 12);
28195 2223630 break;
28196
28197 case FRAMER:
28198 set_drawing_command_args(j, 9);
28199 break;
28200
28201 case CIRCLER:
28202 1056651 set_drawing_command_args(j, 11);
28203 1056651 break;
28204
28205 case ARCR:
28206 set_drawing_command_args(j, 14);
28207 break;
28208
28209 case ELLIPSER:
28210 1850 set_drawing_command_args(j, 12);
28211 1850 break;
28212
28213 case LINER:
28214 937398 set_drawing_command_args(j, 11);
28215 937398 break;
28216
28217 case PUTPIXELR:
28218 383247 set_drawing_command_args(j, 8);
28219 383247 break;
28220
28221 case PIXELARRAYR:
28222 {
28223 set_drawing_command_args(j, 5);
28224 std::vector<int32_t> *v = script_drawing_commands.GetVector();
28225 //for ( int32_t q = 0; q < 6; q++ )
28226 //{
28227 // zprint("PIXELARRAY script_drawing_commands[j][%d] is %d\n", q, script_drawing_commands[j][q]);
28228 //}
28229 int32_t arrayptr = script_drawing_commands[j][2]/10000;
28230 if ( !arrayptr ) //Don't crash because of vector size.
28231 {
28232 Z_scripterrlog("Invalid array pointer %d passed to Screen->PutPixels(). Aborting.", arrayptr);
28233 break;
28234 }
28235 //zprint("Pixelarray array pointer is: %d\n", arrayptr);
28236 int32_t sz = ArrayH::getSize(arrayptr);
28237 //ArrayH::getSize(script_drawing_commands[j][2]/10000);
28238 //zprint("Pixelarray size is: %d\n", sz);
28239 v->resize(sz, 0);
28240 int32_t* pos = &v->at(0);
28241
28242 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, sz);
28243 script_drawing_commands[j].SetVector(v);
28244 break;
28245 }
28246
28247 case TILEARRAYR:
28248 {
28249 set_drawing_command_args(j, 2);
28250 std::vector<int32_t> *v = script_drawing_commands.GetVector();
28251 //for ( int32_t q = 0; q < 6; q++ )
28252 //{
28253 // zprint("PIXELARRAY script_drawing_commands[j][%d] is %d\n", q, script_drawing_commands[j][q]);
28254 //}
28255 int32_t arrayptr = script_drawing_commands[j][2]/10000;
28256 if ( !arrayptr ) //Don't crash because of vector size.
28257 {
28258 Z_scripterrlog("Invalid array pointer %d passed to Screen->DrawTiles(). Aborting.", arrayptr);
28259 break;
28260 }
28261 //zprint("Pixelarray array pointer is: %d\n", arrayptr);
28262 int32_t sz = ArrayH::getSize(arrayptr);
28263 //ArrayH::getSize(script_drawing_commands[j][2]/10000);
28264 //zprint("Pixelarray size is: %d\n", sz);
28265 v->resize(sz, 0);
28266 int32_t* pos = &v->at(0);
28267
28268 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, sz);
28269 script_drawing_commands[j].SetVector(v);
28270 break;
28271 }
28272
28273 case LINESARRAY:
28274 {
28275 set_drawing_command_args(j, 2);
28276 std::vector<int32_t> *v = script_drawing_commands.GetVector();
28277 //for ( int32_t q = 0; q < 6; q++ )
28278 //{
28279 // zprint("PIXELARRAY script_drawing_commands[j][%d] is %d\n", q, script_drawing_commands[j][q]);
28280 //}
28281 int32_t arrayptr = script_drawing_commands[j][2]/10000;
28282 if ( !arrayptr ) //Don't crash because of vector size.
28283 {
28284 Z_scripterrlog("Invalid array pointer %d passed to Screen->Lines(). Aborting.", arrayptr);
28285 break;
28286 }
28287 //zprint("Pixelarray array pointer is: %d\n", arrayptr);
28288 int32_t sz = ArrayH::getSize(arrayptr);
28289 //ArrayH::getSize(script_drawing_commands[j][2]/10000);
28290 //zprint("Pixelarray size is: %d\n", sz);
28291 v->resize(sz, 0);
28292 int32_t* pos = &v->at(0);
28293
28294 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, sz);
28295 script_drawing_commands[j].SetVector(v);
28296 break;
28297 }
28298
28299 /*
28300 historical-old-master
28301 set_drawing_command_args(j, 6);
28302 int32_t count = script_drawing_commands[j][2] / 10000; //todo: errcheck
28303
28304 int32_t* ptr = (int32_t*)script_drawing_commands.AllocateDrawBuffer(3 * count * sizeof(int32_t));
28305 int32_t* p = ptr;
28306
28307 ArrayH::getValues(script_drawing_commands[j][3] / 10000, p, count); p += count;
28308 ArrayH::getValues(script_drawing_commands[j][4] / 10000, p, count); p += count;
28309 ArrayH::getValues(script_drawing_commands[j][5] / 10000, p, count);
28310
28311 script_drawing_commands[j].SetPtr(ptr);
28312 */
28313 // Unused
28314 //const int32_t index = script_drawing_commands[j][19] = j;
28315
28316 //std::array *aptr = script_drawing_commands.GetString();
28317 //ArrayH::getString(script_drawing_commands[j][2] / 10000, *aptr);
28318 //script_drawing_commands[j].SetArray(aptr);
28319 //set_drawing_command_args(j, 2);
28320 //break;
28321
28322 case COMBOARRAYR:
28323 {
28324 set_drawing_command_args(j, 2);
28325 std::vector<int32_t> *v = script_drawing_commands.GetVector();
28326 //for ( int32_t q = 0; q < 6; q++ )
28327 //{
28328 // zprint("PIXELARRAY script_drawing_commands[j][%d] is %d\n", q, script_drawing_commands[j][q]);
28329 //}
28330 int32_t arrayptr = script_drawing_commands[j][2]/10000;
28331 if ( !arrayptr ) //Don't crash because of vector size.
28332 {
28333 Z_scripterrlog("Invalid array pointer %d passed to Screen->DrawCombos(). Aborting.", arrayptr);
28334 break;
28335 }
28336 //zprint("Pixelarray array pointer is: %d\n", arrayptr);
28337 int32_t sz = ArrayH::getSize(arrayptr);
28338 //ArrayH::getSize(script_drawing_commands[j][2]/10000);
28339 //zprint("Pixelarray size is: %d\n", sz);
28340 v->resize(sz, 0);
28341 int32_t* pos = &v->at(0);
28342
28343 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, sz);
28344 script_drawing_commands[j].SetVector(v);
28345 break;
28346 }
28347 case POLYGONR:
28348 {
28349 set_drawing_command_args(j, 5);
28350
28351 int32_t arrayptr = script_drawing_commands[j][3]/10000;
28352 if ( !arrayptr ) //Don't crash because of vector size.
28353 {
28354 Z_scripterrlog("Invalid array pointer %d passed to Screen->Polygon(). Aborting.", arrayptr);
28355 break;
28356 }
28357 int32_t sz = ArrayH::getSize(arrayptr);
28358
28359 std::vector<int32_t> *v = script_drawing_commands.GetVector();
28360 v->resize(sz, 0);
28361
28362 int32_t* pos = &v->at(0);
28363
28364
28365 ArrayH::getValues(script_drawing_commands[j][3] / 10000, pos, sz);
28366 script_drawing_commands[j].SetVector(v);
28367 }
28368 break;
28369
28370 case DRAWTILER:
28371 828501 set_drawing_command_args(j, 15);
28372 828501 break;
28373
28374 case DRAWTILECLOAKEDR:
28375 set_drawing_command_args(j, 7);
28376 break;
28377
28378 case DRAWCOMBOR:
28379 1716768 set_drawing_command_args(j, 16);
28380 1716768 break;
28381
28382 case DRAWCOMBOCLOAKEDR:
28383 set_drawing_command_args(j, 7);
28384 break;
28385
28386 case FASTTILER:
28387 4759287 set_drawing_command_args(j, 6);
28388 4759287 break;
28389
28390 case FASTCOMBOR:
28391 17998198 set_drawing_command_args(j, 6);
28392 17998198 break;
28393
28394 case DRAWCHARR:
28395 936091 set_drawing_command_args(j, 10);
28396 936091 break;
28397
28398 case DRAWINTR:
28399 94003 set_drawing_command_args(j, 11);
28400 94003 break;
28401
28402 case SPLINER:
28403 set_drawing_command_args(j, 11);
28404 break;
28405
28406 case QUADR:
28407 9270 set_drawing_command_args(j, 15);
28408 9270 break;
28409
28410 case TRIANGLER:
28411 set_drawing_command_args(j, 13);
28412 break;
28413
28414 case BITMAPR:
28415 802244 set_drawing_command_args(j, 12);
28416 802244 break;
28417
28418 case BITMAPEXR:
28419 set_drawing_command_args(j, 16);
28420 break;
28421
28422 case DRAWLAYERR:
28423 4128276 set_drawing_command_args(j, 8);
28424 4128276 break;
28425
28426 case DRAWSCREENR:
28427 49303 set_drawing_command_args(j, 6);
28428 49303 break;
28429
28430 case QUAD3DR:
28431 {
28432 set_drawing_command_args(j, 8);
28433 int32_t arrayptr = script_drawing_commands[j][2]/10000;
28434 int32_t sz = ArrayH::getSize(arrayptr);
28435 arrayptr = script_drawing_commands[j][3]/10000;
28436 sz += ArrayH::getSize(arrayptr);
28437 arrayptr = script_drawing_commands[j][4]/10000;
28438 sz += ArrayH::getSize(arrayptr);
28439 arrayptr = script_drawing_commands[j][5]/10000;
28440 sz += ArrayH::getSize(arrayptr);
28441 std::vector<int32_t> *v = script_drawing_commands.GetVector();
28442 v->resize(sz, 0);
28443
28444 int32_t* pos = &v->at(0);
28445 int32_t* uv = &v->at(12);
28446 int32_t* col = &v->at(20);
28447 int32_t* size = &v->at(24);
28448
28449 ArrayH::getValues((script_drawing_commands[j][2] / 10000), pos, 12);
28450 ArrayH::getValues((script_drawing_commands[j][3] / 10000), uv, 8);
28451 ArrayH::getValues((script_drawing_commands[j][4] / 10000), col, 4);
28452 //FFCore.getValues2(script_drawing_commands[j][5] / 10000, size, 2);
28453 ArrayH::getValues((script_drawing_commands[j][5] / 10000), size, 2);
28454
28455 script_drawing_commands[j].SetVector(v);
28456 }
28457 break;
28458
28459 case TRIANGLE3DR:
28460 {
28461 set_drawing_command_args(j, 8);
28462
28463 int32_t arrayptr = script_drawing_commands[j][2]/10000;
28464 int32_t sz = ArrayH::getSize(arrayptr);
28465 arrayptr = script_drawing_commands[j][3]/10000;
28466 sz += ArrayH::getSize(arrayptr);
28467 arrayptr = script_drawing_commands[j][4]/10000;
28468 sz += ArrayH::getSize(arrayptr);
28469 arrayptr = script_drawing_commands[j][5]/10000;
28470 sz += ArrayH::getSize(arrayptr);
28471
28472 std::vector<int32_t> *v = script_drawing_commands.GetVector();
28473 v->resize(sz, 0);
28474
28475 int32_t* pos = &v->at(0);
28476 int32_t* uv = &v->at(9);
28477 int32_t* col = &v->at(15);
28478 int32_t* size = &v->at(18);
28479
28480 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, 8);
28481 ArrayH::getValues(script_drawing_commands[j][3] / 10000, uv, 6);
28482 ArrayH::getValues(script_drawing_commands[j][4] / 10000, col, 3);
28483 ArrayH::getValues(script_drawing_commands[j][5] / 10000, size, 2);
28484
28485 script_drawing_commands[j].SetVector(v);
28486 }
28487 break;
28488
28489 case DRAWSTRINGR:
28490 {
28491 1240874 set_drawing_command_args(j, 9);
28492 // Unused
28493 //const int32_t index = script_drawing_commands[j][19] = j;
28494
28495 1240874 string *str = script_drawing_commands.GetString();
28496 1240874 ArrayH::getString(script_drawing_commands[j][8] / 10000, *str, 256);
28497 1240874 script_drawing_commands[j].SetString(str);
28498 }
28499 1240874 break;
28500
28501 case DRAWSTRINGR2:
28502 {
28503 150650 set_drawing_command_args(j, 11);
28504 // Unused
28505 //const int32_t index = script_drawing_commands[j][19] = j;
28506
28507 150650 string *str = script_drawing_commands.GetString();
28508 150650 ArrayH::getString(script_drawing_commands[j][8] / 10000, *str, 256);
28509 150650 script_drawing_commands[j].SetString(str);
28510 }
28511 150650 break;
28512
28513 case BMPRECTR:
28514 7818 set_user_bitmap_command_args(j, 12); script_drawing_commands[j][17] = SH::read_stack(ri->sp+12);
28515 //Pop the args off the stack first. Then pop the pointer and push it to sdci[17].
28516 //The pointer for the bitmap variable (its literal value) is always ri->sp+numargs, so, with 12 args, it is sp+12.
28517 7818 break;
28518
28519 case BMPFRAMER:
28520 set_user_bitmap_command_args(j, 9);
28521 script_drawing_commands[j][17] = SH::read_stack(ri->sp+9);
28522 break;
28523
28524 case CLEARBITMAP:
28525 {
28526 23013 set_user_bitmap_command_args(j, 1);
28527 23013 script_drawing_commands[j][17] = SH::read_stack(ri->sp+1);
28528 23013 break;
28529 }
28530 case BITMAPCLEARTOCOLOR:
28531 {
28532 2790 set_user_bitmap_command_args(j, 2);
28533 2790 script_drawing_commands[j][17] = SH::read_stack(ri->sp+2);
28534 2790 break;
28535 }
28536 case REGENERATEBITMAP:
28537 {
28538 26528 set_user_bitmap_command_args(j, 3);
28539 26528 script_drawing_commands[j][17] = SH::read_stack(ri->sp+3);
28540 26528 break;
28541 }
28542 case BMPPOLYGONR:
28543 {
28544 set_user_bitmap_command_args(j, 5);
28545 script_drawing_commands[j][17] = SH::read_stack(ri->sp+5);
28546 int32_t arrayptr = script_drawing_commands[j][3]/10000;
28547 if ( !arrayptr ) //Don't crash because of vector size.
28548 {
28549 Z_scripterrlog("Invalid array pointer %d passed to Screen->Polygon(). Aborting.", arrayptr);
28550 break;
28551 }
28552 int32_t sz = ArrayH::getSize(arrayptr);
28553
28554 std::vector<int32_t> *v = script_drawing_commands.GetVector();
28555 v->resize(sz, 0);
28556
28557 int32_t* pos = &v->at(0);
28558
28559
28560 ArrayH::getValues(script_drawing_commands[j][3] / 10000, pos, sz);
28561 script_drawing_commands[j].SetVector(v);
28562 }
28563 break;
28564 case READBITMAP:
28565 {
28566 //zprint("Calling %s\n","READBITMAP");
28567 set_user_bitmap_command_args(j, 2);
28568 script_drawing_commands[j][17] = SH::read_stack(ri->sp+2);
28569 string *str = script_drawing_commands.GetString();
28570 ArrayH::getString(script_drawing_commands[j][2] / 10000, *str, 256);
28571
28572 //char cptr = new char[str->size()+1]; // +1 to account for \0 byte
28573 //strncpy(cptr, str->c_str(), str->size());
28574
28575 if(get_qr(qr_BITMAP_AND_FILESYSTEM_PATHS_ALWAYS_RELATIVE))
28576 {
28577 char buf[2048+1] = {0};
28578 if(FFCore.get_scriptfile_path(buf, str->c_str()))
28579 (*str) = buf;
28580 }
28581 regulate_path(*str);
28582
28583 //zprint("READBITMAP string is %s\n", cptr);
28584
28585 script_drawing_commands[j].SetString(str);
28586 break;
28587 }
28588 case WRITEBITMAP:
28589 {
28590 //zprint("Calling %s\n","WRITEBITMAP");
28591 set_user_bitmap_command_args(j, 3);
28592 script_drawing_commands[j][17] = SH::read_stack(ri->sp+3);
28593 std::string *str = script_drawing_commands.GetString();
28594 ArrayH::getString(script_drawing_commands[j][2] / 10000, *str, 256);
28595
28596
28597 //char *cptr = new char[str->size()+1]; // +1 to account for \0 byte
28598 //strncpy(cptr, str->c_str(), str->size());
28599
28600 if(get_qr(qr_BITMAP_AND_FILESYSTEM_PATHS_ALWAYS_RELATIVE))
28601 {
28602 char buf[2048+1] = {0};
28603 if(FFCore.get_scriptfile_path(buf, str->c_str()))
28604 (*str) = buf;
28605 }
28606 regulate_path(*str);
28607
28608 //zprint("WRITEBITMAP string is %s\n", cptr);
28609 script_drawing_commands[j].SetString(str);
28610 break;
28611 }
28612
28613 1480 case BMPCIRCLER: set_user_bitmap_command_args(j, 11); script_drawing_commands[j][17] = SH::read_stack(ri->sp+11); break;
28614 case BMPARCR: set_user_bitmap_command_args(j, 14); script_drawing_commands[j][17] = SH::read_stack(ri->sp+14); break;
28615 502 case BMPELLIPSER: set_user_bitmap_command_args(j, 12); script_drawing_commands[j][17] = SH::read_stack(ri->sp+12); break;
28616 144 case BMPLINER: set_user_bitmap_command_args(j, 11); script_drawing_commands[j][17] = SH::read_stack(ri->sp+11); break;
28617 case BMPSPLINER: set_user_bitmap_command_args(j, 11); script_drawing_commands[j][17] = SH::read_stack(ri->sp+11); break;
28618 80910 case BMPPUTPIXELR: set_user_bitmap_command_args(j, 8); script_drawing_commands[j][17] = SH::read_stack(ri->sp+8); break;
28619 59173 case BMPDRAWTILER: set_user_bitmap_command_args(j, 15); script_drawing_commands[j][17] = SH::read_stack(ri->sp+15); break;
28620 case BMPDRAWTILECLOAKEDR: set_user_bitmap_command_args(j, 7); script_drawing_commands[j][17] = SH::read_stack(ri->sp+7); break;
28621 824 case BMPDRAWCOMBOR: set_user_bitmap_command_args(j, 16); script_drawing_commands[j][17] = SH::read_stack(ri->sp+16); break;
28622 case BMPDRAWCOMBOCLOAKEDR: set_user_bitmap_command_args(j, 7); script_drawing_commands[j][17] = SH::read_stack(ri->sp+7); break;
28623 166191 case BMPFASTTILER: set_user_bitmap_command_args(j, 6); script_drawing_commands[j][17] = SH::read_stack(ri->sp+6); break;
28624 784 case BMPFASTCOMBOR: set_user_bitmap_command_args(j, 6); script_drawing_commands[j][17] = SH::read_stack(ri->sp+6); break;
28625 case BMPDRAWCHARR: set_user_bitmap_command_args(j, 10); script_drawing_commands[j][17] = SH::read_stack(ri->sp+10); break;
28626 case BMPDRAWINTR: set_user_bitmap_command_args(j, 11); script_drawing_commands[j][17] = SH::read_stack(ri->sp+11); break;
28627 case BMPDRAWSTRINGR:
28628 {
28629 set_user_bitmap_command_args(j, 9);
28630 script_drawing_commands[j][17] = SH::read_stack(ri->sp+9);
28631 // Unused
28632 //const int32_t index = script_drawing_commands[j][19] = j;
28633
28634 string *str = script_drawing_commands.GetString();
28635 ArrayH::getString(script_drawing_commands[j][8] / 10000, *str, 256);
28636 script_drawing_commands[j].SetString(str);
28637
28638 }
28639 break;
28640 case BMPDRAWSTRINGR2:
28641 {
28642 45504 set_user_bitmap_command_args(j, 11);
28643 45504 script_drawing_commands[j][17] = SH::read_stack(ri->sp+11);
28644 // Unused
28645 //const int32_t index = script_drawing_commands[j][19] = j;
28646
28647 45504 string *str = script_drawing_commands.GetString();
28648 45504 ArrayH::getString(script_drawing_commands[j][8] / 10000, *str, 256);
28649 45504 script_drawing_commands[j].SetString(str);
28650
28651 }
28652 45504 break;
28653 case BMPQUADR: set_user_bitmap_command_args(j, 16); script_drawing_commands[j][17] = SH::read_stack(ri->sp+16); break;
28654 case BMPQUAD3DR:
28655 {
28656 set_drawing_command_args(j, 9);
28657 std::vector<int32_t> *v = script_drawing_commands.GetVector();
28658 v->resize(26, 0);
28659
28660 int32_t* pos = &v->at(0);
28661 int32_t* uv = &v->at(12);
28662 int32_t* col = &v->at(20);
28663 int32_t* size = &v->at(24);
28664
28665
28666 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, 12);
28667 ArrayH::getValues(script_drawing_commands[j][3] / 10000, uv, 8);
28668 ArrayH::getValues(script_drawing_commands[j][4] / 10000, col, 4);
28669 ArrayH::getValues(script_drawing_commands[j][5] / 10000, size, 2);
28670
28671 script_drawing_commands[j].SetVector(v);
28672 script_drawing_commands[j][17] = SH::read_stack(ri->sp+9);
28673
28674 }
28675 break;
28676 case BMPTRIANGLER: set_user_bitmap_command_args(j, 14); script_drawing_commands[j][17] = SH::read_stack(ri->sp+14); break;
28677 case BMPTRIANGLE3DR:
28678 {
28679 set_drawing_command_args(j, 9);
28680
28681 std::vector<int32_t> *v = script_drawing_commands.GetVector();
28682 v->resize(20, 0);
28683
28684 int32_t* pos = &v->at(0);
28685 int32_t* uv = &v->at(9);
28686 int32_t* col = &v->at(15);
28687 int32_t* size = &v->at(18);
28688
28689
28690 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, 8);
28691 ArrayH::getValues(script_drawing_commands[j][3] / 10000, uv, 6);
28692 ArrayH::getValues(script_drawing_commands[j][4] / 10000, col, 3);
28693 ArrayH::getValues(script_drawing_commands[j][5] / 10000, size, 2);
28694
28695 script_drawing_commands[j].SetVector(v);
28696 script_drawing_commands[j][17] = SH::read_stack(ri->sp+9);
28697 break;
28698 }
28699
28700 case BMPDRAWLAYERR:
28701 1173 set_user_bitmap_command_args(j, 8);
28702 1173 script_drawing_commands[j][17] = SH::read_stack(ri->sp+8);
28703 1173 break;
28704 case BMPDRAWLAYERSOLIDR:
28705 case BMPDRAWLAYERCFLAGR:
28706 case BMPDRAWLAYERCTYPER:
28707 case BMPDRAWLAYERCIFLAGR:
28708 case BMPDRAWLAYERSOLIDITYR: set_user_bitmap_command_args(j, 9); script_drawing_commands[j][17] = SH::read_stack(ri->sp+9); break;
28709 case BMPDRAWSCREENR:
28710 case BMPDRAWSCREENSOLIDR:
28711 case BMPDRAWSCREENSOLID2R:
28712 case BMPDRAWSCREENCOMBOFR:
28713 case BMPDRAWSCREENCOMBOIR:
28714 case BMPDRAWSCREENCOMBOTR:
28715 2051 set_user_bitmap_command_args(j, 6); script_drawing_commands[j][17] = SH::read_stack(ri->sp+6); break;
28716 case BITMAPGETPIXEL:
28717 {
28718 //UNUSED
28719 // for(int32_t q = 0; q < 20; q++)
28720 // {
28721 // Z_scripterrlog("getpixel SH::read_stack(ri->sp+%d) is: %d\n", q, SH::read_stack(ri->sp+q));
28722 // }
28723 set_user_bitmap_command_args(j, 3); script_drawing_commands[j][17] = SH::read_stack(ri->sp+3);
28724 break;
28725 }
28726 case BMPBLIT:
28727 {
28728 234762 set_user_bitmap_command_args(j, 16);
28729 //for(int32_t q = 0; q < 8; ++q )
28730 //Z_scripterrlog("FFscript blit() ri->d[%d] is: %d\n", q, ri->d[q]);
28731 234762 script_drawing_commands[j][17] = SH::read_stack(ri->sp+16);
28732 234762 break;
28733 }
28734 case BMPBLITTO:
28735 {
28736 909 set_user_bitmap_command_args(j, 16);
28737 //for(int32_t q = 0; q < 8; ++q )
28738 //Z_scripterrlog("FFscript blit() ri->d[%d] is: %d\n", q, ri->d[q]);
28739 909 script_drawing_commands[j][17] = SH::read_stack(ri->sp+16);
28740 909 break;
28741 }
28742 case BMPMODE7:
28743 {
28744 set_user_bitmap_command_args(j, 13);
28745 //for(int32_t q = 0; q < 8; ++q )
28746 //Z_scripterrlog("FFscript blit() ri->d[%d] is: %d\n", q, ri->d[q]);
28747 script_drawing_commands[j][17] = SH::read_stack(ri->sp+13);
28748 break;
28749 }
28750
28751 case BMPWRITETILE:
28752 {
28753 set_user_bitmap_command_args(j, 6);
28754 script_drawing_commands[j][17] = SH::read_stack(ri->sp+6);
28755 break;
28756 }
28757 case BMPDITHER:
28758 {
28759 set_user_bitmap_command_args(j, 5);
28760 script_drawing_commands[j][17] = SH::read_stack(ri->sp+5);
28761 break;
28762 }
28763 case BMPMASKDRAW:
28764 {
28765 906 set_user_bitmap_command_args(j, 3);
28766 906 script_drawing_commands[j][4] = 0x01 * 10000L;
28767 906 script_drawing_commands[j][5] = 0xFF * 10000L;
28768 906 script_drawing_commands[j][17] = SH::read_stack(ri->sp+3);
28769 906 break;
28770 }
28771 case BMPMASKDRAW2:
28772 {
28773 set_user_bitmap_command_args(j, 4);
28774 script_drawing_commands[j][5] = script_drawing_commands[j][4];
28775 script_drawing_commands[j][0] = BMPMASKDRAW;
28776 script_drawing_commands[j][17] = SH::read_stack(ri->sp+4);
28777 break;
28778 }
28779 case BMPMASKDRAW3:
28780 {
28781 set_user_bitmap_command_args(j, 5);
28782 script_drawing_commands[j][0] = BMPMASKDRAW;
28783 script_drawing_commands[j][17] = SH::read_stack(ri->sp+5);
28784 break;
28785 }
28786 case BMPMASKBLIT:
28787 {
28788 set_user_bitmap_command_args(j, 4);
28789 script_drawing_commands[j][5] = 0x01 * 10000L;
28790 script_drawing_commands[j][6] = 0xFF * 10000L;
28791 script_drawing_commands[j][17] = SH::read_stack(ri->sp+4);
28792 break;
28793 }
28794 case BMPMASKBLIT2:
28795 {
28796 set_user_bitmap_command_args(j, 5);
28797 script_drawing_commands[j][6] = script_drawing_commands[j][5];
28798 script_drawing_commands[j][0] = BMPMASKBLIT;
28799 script_drawing_commands[j][17] = SH::read_stack(ri->sp+5);
28800 break;
28801 }
28802 case BMPMASKBLIT3:
28803 {
28804 set_user_bitmap_command_args(j, 6);
28805 script_drawing_commands[j][0] = BMPMASKBLIT;
28806 script_drawing_commands[j][17] = SH::read_stack(ri->sp+6);
28807 break;
28808 }
28809 case BMPREPLCOLOR:
28810 case BMPSHIFTCOLOR:
28811 {
28812 6363 set_user_bitmap_command_args(j, 4);
28813 6363 script_drawing_commands[j][17] = SH::read_stack(ri->sp+4);
28814 6363 break;
28815 }
28816 }
28817 37978066 script_drawing_commands.mark_dirty(script_drawing_commands[j][1]/10000);
28818 37978066 }
28819
28820 3535588 void do_set_rendertarget(bool)
28821 {
28822 3535588 int32_t target = int32_t(SH::read_stack(ri->sp) / 10000);
28823 3535588 zscriptDrawingRenderTarget->SetCurrentRenderTarget(target);
28824 3535588 }
28825
28826 170815 void do_sfx(const bool v)
28827 {
28828 170815 int32_t ID = SH::get_arg(sarg1, v) / 10000;
28829
28830
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 170811 times.
170815 if(BC::checkSFXID(ID, "Game->PlaySound") != SH::_NoError)
28831 4 return;
28832
28833 170811 sfx(ID);
28834 170815 }
28835
28836 void do_sfx_ex(const bool restart)
28837 {
28838 int32_t ID = SH::read_stack(ri->sp + 4) / 10000;
28839 int32_t vol = vbound(SH::read_stack(ri->sp + 3), 0, 10000 * 100);
28840 int32_t pan = vbound(SH::read_stack(ri->sp + 2)/10000 + 128, 0, 255);
28841 int32_t freq = SH::read_stack(ri->sp + 1);
28842 bool loop = SH::read_stack(ri->sp) / 10000;
28843
28844 if (BC::checkSFXID(ID, restart?"Audio->PlaySound":"Audio->AdjustSound") != SH::_NoError)
28845 return;
28846
28847 if (!restart && !sfx_allocated(ID))
28848 return;
28849
28850 sfx(ID, pan, loop, restart, vol, freq);
28851 }
28852
28853 void do_get_sfx_completion()
28854 {
28855 int32_t ID = get_register(sarg1) / 10000;
28856
28857 // TODO: record results for replays
28858
28859 if (!sfx_allocated(ID))
28860 {
28861 set_register(sarg1, -10000);
28862 return;
28863 }
28864
28865 uint64_t sample_pos = voice_get_position(sfx_voice[ID]);
28866
28867 if (sample_pos < 0)
28868 {
28869 set_register(sarg1, -10000);
28870 return;
28871 }
28872
28873 uint32_t sample_length = sfx_get_length(ID);
28874 uint64_t res = (sample_pos * 10000 * 100) / sample_length;
28875 set_register(sarg1, int32_t(res));
28876 }
28877
28878 int32_t FFScript::do_get_internal_uid_npc(int32_t index)
28879 {
28880 return ((int32_t)guys.spr(index)->getUID());
28881 }
28882 int32_t FFScript::do_get_internal_uid_item(int32_t index)
28883 {
28884 return ((int32_t)items.spr(index)->getUID());
28885 }
28886 int32_t FFScript::do_get_internal_uid_lweapon(int32_t index)
28887 {
28888 return ((int32_t)Lwpns.spr(index)->getUID());
28889 }
28890 int32_t FFScript::do_get_internal_uid_eweapon(int32_t index)
28891 {
28892 return ((int32_t)Ewpns.spr(index)->getUID());
28893 }
28894
28895 void FFScript::AlloffLimited(int32_t flagset)
28896 {
28897 clear_bitmap(msg_txt_display_buf);
28898 clear_bitmap(msg_bg_display_buf);
28899 clear_bitmap(msg_portrait_display_buf);
28900 set_clip_state(msg_txt_display_buf, 1);
28901 set_clip_state(msg_bg_display_buf, 1);
28902 set_clip_state(msg_portrait_display_buf, 1);
28903
28904
28905 clear_bitmap(pricesdisplaybuf);
28906 set_clip_state(pricesdisplaybuf, 1);
28907
28908 if(items.idCount(iPile))
28909 {
28910 loadlvlpal(DMaps[currdmap].color);
28911 }
28912
28913 /*
28914
28915 #define warpFlagCLEARITEMS 0x200
28916 #define warpFlagCLEARGUYS 0x400
28917 #define warpFlagCLEARLWEAPONS 0x800
28918 #define warpFlagCLEAREWEAPONS 0x1000
28919 #define warpFlagCLEARHOOKSHOT 0x2000
28920 #define warpFlagCLEARDECORATIONS 0x4000
28921 #define warpFlagCLEARPARTICLES 0x8000
28922 */
28923
28924 if ( (flagset&warpFlagCLEARITEMS) ) items.clear();
28925 if ( (flagset&warpFlagCLEARGUYS) ) guys.clear();
28926 if ( (flagset&warpFlagCLEARLWEAPONS) ) Lwpns.clear();
28927 if ( (flagset&warpFlagCLEAREWEAPONS) ) Ewpns.clear();
28928 if ( (flagset&warpFlagCLEARHOOKSHOT) )
28929 {
28930 chainlinks.clear();
28931 Hero.reset_hookshot();
28932 }
28933 if ( (flagset&warpFlagCLEARDECORATIONS) ) decorations.clear();
28934 if ( (flagset&warpFlagCLEARPARTICLES) ) particles.clear();
28935 clearScriptHelperData();
28936
28937
28938
28939 clearScriptHelperData();
28940
28941 lensclk = 0;
28942 lensid=-1;
28943 drawguys=true;
28944 down_control_states[btnUp] =
28945 down_control_states[btnDown] =
28946 down_control_states[btnLeft] =
28947 down_control_states[btnRight] =
28948 down_control_states[btnA] =
28949 down_control_states[btnB] =
28950 down_control_states[btnS] = true;
28951
28952 if(watch && !cheat_superman)
28953 {
28954 Hero.setClock(false);
28955 }
28956
28957 // if(watch)
28958 // Hero.setClock(false);
28959 watch=freeze_guys=loaded_guys=loaded_enemies=blockpath=false;
28960
28961 for(int32_t i=0; i<176; i++)
28962 guygrid[i]=0;
28963
28964 for(int32_t i=0; i<MAXFFCS; i++)
28965 guygridffc[i]=0;
28966
28967
28968 sle_clk=0;
28969
28970 if(usebombpal)
28971 {
28972 memcpy(RAMpal, tempbombpal, PAL_SIZE*sizeof(RGB));
28973 refreshpal=true;
28974 usebombpal=false;
28975 }
28976
28977
28978 }
28979
28980 32 void doWarpEffect(int32_t warpEffect, bool out)
28981 {
28982
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
32 switch(warpEffect)
28983 {
28984 case warpEffectZap:
28985 if(out) zapout();
28986 else zapin();
28987 break;
28988 case warpEffectWave:
28989 if(out) wavyout(false);
28990 else wavyin();
28991 break;
28992 case warpEffectInstant:
28993 if(out) blackscr(30,true);
28994 break;
28995 case warpEffectMozaic:
28996 //!TODO Unimplemented
28997 break;
28998 case warpEffectOpen:
28999 if(out) closescreen();
29000 else openscreen();
29001 break;
29002 }
29003 32 }
29004
29005 void FFScript::queueWarp(int32_t wtype, int32_t tdm, int32_t tscr, int32_t wx, int32_t wy,
29006 int32_t weff, int32_t wsfx, int32_t wflag, int32_t wdir)
29007 {
29008 warpex[wexActive] = 1;
29009 warpex[wexType] = wtype;
29010 warpex[wexDMap] = tdm;
29011 warpex[wexScreen] = tscr;
29012 warpex[wexX] = wx;
29013 warpex[wexY] = wy;
29014 warpex[wexEffect] = weff;
29015 warpex[wexSound] = wsfx;
29016 warpex[wexFlags] = wflag;
29017 warpex[wexDir] = wdir;
29018 }
29019
29020 16 bool FFScript::warp_player(int32_t warpType, int32_t dmapID, int32_t scrID, int32_t warpDestX, int32_t warpDestY, int32_t warpEffect, int32_t warpSound, int32_t warpFlags, int32_t heroFacesDir)
29021 {
29022 if(DEVLOGGING)
29023 {
29024 zprint("FFScript::warp_player() arg %s is: %d \n", "warpType", warpType);
29025 zprint("FFScript::warp_player() arg %s is: %d \n", "dmapID", dmapID);
29026 zprint("FFScript::warp_player() arg %s is: %d \n", "scrID", scrID);
29027 zprint("FFScript::warp_player() arg %s is: %d \n", "warpDestX", warpDestX);
29028 zprint("FFScript::warp_player() arg %s is: %d \n", "warpDestY", warpDestY);
29029 zprint("FFScript::warp_player() arg %s is: %d \n", "warpEffect", warpEffect);
29030 zprint("FFScript::warp_player() arg %s is: %d \n", "warpSound", warpSound);
29031 zprint("FFScript::warp_player() arg %s is: %d \n", "warpFlags", warpFlags);
29032 zprint("FFScript::warp_player() arg %s is: %d \n", "heroFacesDir", heroFacesDir);
29033 }
29034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( ((unsigned)dmapID) >= MAXDMAPS )
29035 {
29036 Z_scripterrlog("Invalid DMap ID (%d) passed to WarpEx(). Aborting.\n", dmapID);
29037 return false;
29038 }
29039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( ((unsigned)scrID) >= MAPSCRS )
29040 {
29041 Z_scripterrlog("Invalid Screen ID (%d) passed to WarpEx(). Aborting.\n", scrID);
29042 return false;
29043 }
29044 //Extra sanity guard.
29045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( DMaps[dmapID].map*MAPSCRS+DMaps[dmapID].xoff+scrID >= (int32_t)TheMaps.size() )
29046 {
29047 Z_scripterrlog("Invalid destination passed to WarpEx(). Aborting.\n");
29048 return false;
29049 }
29050 16 byte t = 0;
29051 16 t=(currscr<128)?0:1;
29052 16 bool overlay=false;
29053 16 bool intradmap = (dmapID == currdmap);
29054 16 int32_t olddmap = currdmap;
29055 //if ( intradmap )
29056 //{
29057 // initZScriptDMapScripts(); //Not needed.
29058 //}
29059
29060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( warpType == wtNOWARP ) { Z_eventlog("Used a Cancel Warped to DMap %d: %s, screen %d", currdmap, DMaps[currdmap].name,currscr); return false; }
29061 16 int32_t mapID = (DMaps[dmapID].map+1);
29062 16 int32_t dest_dmap_xoff = DMaps[dmapID].xoff;
29063 //mapscr *m = &TheMaps[mapID * MAPSCRS + scrID];
29064
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 mapscr *m = &TheMaps[(zc_max((mapID)-1,0) * MAPSCRS + dest_dmap_xoff + scrID)];
29065
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( warpFlags&warpFlagNOSTEPFORWARD ) FFCore.temp_no_stepforward = 1;
29066 16 int32_t wx = 0, wy = 0;
29067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( warpDestX < 0 )
29068 {
29069 if(DEVLOGGING) zprint("WarpEx() was set to warp return point:%d\n", warpDestY);
29070
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( (unsigned)warpDestY < 4 )
29071 {
29072 16 wx = m->warpreturnx[warpDestY];
29073 16 wy = m->warpreturny[warpDestY];
29074 if(DEVLOGGING)
29075 {
29076 zprint("WarpEx Return Point X is: %d\n",wx);
29077 zprint("WarpEx Return Point Y is: %d\n",wy);
29078 }
29079 16 }
29080 else
29081 {
29082 if ( warpDestY == 5 || warpDestY < 0)
29083 {
29084 //Pit warp
29085 wx = Hero.getX();
29086 wy = Hero.getY();
29087 }
29088 else
29089 {
29090 Z_scripterrlog("Invalid Warp Return Square Type (%d) provided as an arg to Player->WarpEx().\n",warpDestY);
29091 return false;
29092 }
29093 }
29094 16 }
29095 else
29096 {
29097 if ( (unsigned)warpDestX < 256 && (unsigned)warpDestY < 176 )
29098 {
29099 wx = warpDestX;
29100 wy = warpDestY;
29101 }
29102 else
29103 {
29104 Z_scripterrlog("Invalid pixel coordinates of x = %d, y = %d, supplied to Player->WarpEx()\n",warpDestX,warpDestY);
29105 return false;
29106 }
29107
29108 }
29109 //zprint("FFCore.warp_player reached line: %d \n", 15918);
29110 //warp coordinates are wx, wy, not x, y! -Z
29111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( !(warpFlags&warpFlagDONTKILLSCRIPTDRAWS) ) script_drawing_commands.Clear();
29112 //we also need to check if dmaps are sideview here! -Z
29113 //Likewise, we need to add that check to the normal Hero:;dowarp(0
29114 16 bool wasSideview = isSideViewGravity(t); //((tmpscr[t].flags7 & fSIDEVIEW)!=0 || DMaps[currdmap].sideview) && !ignoreSideview;
29115 //zprint("FFCore.warp_player reached line: %d \n", 15925);
29116 //zprint("FFCore.warp_player war type is: %d \n", warpType);
29117
29118 //int32_t last_entr_scr = -1;
29119 //int32_t last_entr_dmap = -1;
29120
29121
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( warpType < wtEXIT ) warpType = wtIWARP; //Sanity check. We can't use wtCave, or wtPassage, with scritped warps at present.
29122 16 Hero.is_warping = true;
29123
1/5
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
16 switch(warpType)
29124 {
29125
29126 //wtCAVE, wtPASS, wtEXIT, wtSCROLL, wtIWARP, wtIWARPBLK, wtIWARPOPEN,
29127 //wtIWARPZAP, wtIWARPWAVE, wtNOWARP, wtWHISTLE, wtMAX
29128
29129
29130 case wtIWARP:
29131 case wtIWARPBLK:
29132 case wtIWARPOPEN:
29133 case wtIWARPZAP:
29134 case wtIWARPWAVE:
29135 {
29136 //zprint("FFCore.warp_player reached line: %d \n", 15936);
29137 16 bool wasswimming = (Hero.getAction()==swimming);
29138 16 bool wassideswim = (Hero.getAction()==sideswimming);
29139 16 int32_t olddiveclk = Hero.diveclk;
29140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( !(warpFlags&warpFlagDONTCLEARSPRITES) )
29141 {
29142 16 ALLOFF();
29143 16 }
29144 else FFCore.AlloffLimited(warpFlags);
29145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( !(warpFlags&warpFlagDONTKILLMUSIC) ) music_stop();
29146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( !(warpFlags&warpFlagDONTKILLSOUNDS) ) kill_sfx();
29147 16 sfx(warpSound);
29148
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(wasswimming)
29149 {
29150 Hero.setAction(swimming); FFCore.setHeroAction(swimming);
29151 Hero.diveclk = olddiveclk;
29152 }
29153
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(wassideswim)
29154 {
29155 Hero.setAction(sideswimming); FFCore.setHeroAction(sideswimming);
29156 Hero.diveclk = 0;
29157 }
29158 //zprint("FFCore.warp_player reached line: %d \n", 15948);
29159 16 doWarpEffect(warpEffect, true);
29160 //zprint("FFCore.warp_player reached line: %d \n", 15973);
29161 16 int32_t c = DMaps[currdmap].color;
29162 16 bool changedlevel = false;
29163 16 bool changeddmap = false;
29164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(currdmap != dmapID)
29165 {
29166 16 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
29167 16 changeddmap = true;
29168 16 }
29169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(dlevel != DMaps[dmapID].level)
29170 {
29171 16 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
29172 16 changedlevel = true;
29173 16 }
29174 16 dlevel = DMaps[dmapID].level;
29175 16 currdmap = dmapID;
29176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(changeddmap)
29177 {
29178 16 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
29179 16 }
29180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(changedlevel)
29181 {
29182 16 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
29183 16 }
29184 16 currmap = DMaps[currdmap].map;
29185 16 init_dmap();
29186 16 update_subscreens(dmapID);
29187
29188 16 ringcolor(false);
29189
29190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(DMaps[currdmap].color != c)
29191 16 loadlvlpal(DMaps[currdmap].color);
29192
29193 16 homescr = currscr = scrID + DMaps[currdmap].xoff;
29194
29195 16 lightingInstant(); // Also sets naturaldark
29196
29197 16 loadscr(0,currdmap,currscr,-1,overlay);
29198
29199 16 Hero.x = (zfix)wx;
29200 16 Hero.y = (zfix)wy;
29201
29202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 switch(heroFacesDir)
29203 {
29204 case up:
29205 case down:
29206 case left:
29207 case right:
29208 Hero.dir = heroFacesDir;
29209 break;
29210 default:
29211
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if((int32_t)Hero.x==(zfix)0)
29212 {
29213 Hero.dir=right;
29214 }
29215
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if((int32_t)Hero.x==(zfix)240)
29216 {
29217 Hero.dir=left;
29218 }
29219
29220
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if((int32_t)Hero.y==(zfix)0)
29221 {
29222 Hero.dir=down;
29223 }
29224
29225
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if((int32_t)Hero.y==(zfix)160)
29226 {
29227 Hero.dir=up;
29228 }
29229 16 }
29230
29231 16 markBmap(Hero.dir^1);
29232
29233
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
16 if(iswaterex(MAPCOMBO((int32_t)Hero.x,(int32_t)Hero.y+8), currmap, currscr, -1, Hero.x, Hero.y+8, true) && _walkflag((int32_t)Hero.x,(int32_t)Hero.y+8,0) && current_item(itype_flippers))
29234 {
29235 Hero.hopclk=0xFF;
29236 Hero.attackclk = Hero.charging = Hero.spins = 0;
29237 if (isSideViewHero() && get_qr(qr_SIDESWIM)) {Hero.setAction(sideswimming); FFCore.setHeroAction(sideswimming);}
29238 else {Hero.setAction(swimming); FFCore.setHeroAction(swimming);}
29239 }
29240 else
29241 {
29242 16 Hero.setAction(none); FFCore.setHeroAction(none);
29243 }
29244
29245 //preloaded freeform combos
29246 16 ffscript_engine(true);
29247
29248 16 putscr(scrollbuf,0,0,tmpscr);
29249 16 putscrdoors(scrollbuf,0,0,tmpscr);
29250
29251 16 doWarpEffect(warpEffect, false);
29252 16 show_subscreen_life=true;
29253 16 show_subscreen_numbers=true;
29254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( !(warpFlags&warpFlagDONTKILLMUSIC) ) Play_Level_Music();
29255 16 currcset=DMaps[currdmap].color;
29256 16 dointro();
29257 16 Hero.set_respawn_point();
29258 16 Hero.trySideviewLadder();
29259
29260 16 break;
29261 }
29262
29263
29264 case wtEXIT:
29265 {
29266 //zprint("%s was called with a warp type of Entrance/Exit\n", "Player->WarpEx()");
29267 lighting(false,false,pal_litRESETONLY);//Reset permLit, and do nothing else; lighting was not otherwise called on a wtEXIT warp.
29268 ALLOFF();
29269 if ( !(warpFlags&warpFlagDONTKILLMUSIC) ) music_stop();
29270 if ( !(warpFlags&warpFlagDONTKILLSOUNDS) ) kill_sfx();
29271 sfx(warpSound);
29272 blackscr(30,false);
29273 bool changedlevel = false;
29274 bool changeddmap = false;
29275 if(currdmap != dmapID)
29276 {
29277 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
29278 changeddmap = true;
29279 }
29280 if(dlevel != DMaps[dmapID].level)
29281 {
29282 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
29283 changedlevel = true;
29284 }
29285 dlevel = DMaps[dmapID].level;
29286 currdmap = dmapID;
29287 if(changeddmap)
29288 {
29289 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
29290 }
29291 if(changedlevel)
29292 {
29293 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
29294 }
29295 currmap=DMaps[currdmap].map;
29296 init_dmap();
29297 update_subscreens(dmapID);
29298 loadfullpal();
29299 ringcolor(false);
29300 loadlvlpal(DMaps[currdmap].color);
29301 //lastentrance_dmap = currdmap;
29302 homescr = currscr = scrID + DMaps[currdmap].xoff;
29303 loadscr(0,currdmap,currscr,-1,overlay);
29304
29305 if((tmpscr->flags&fDARK) && !get_qr(qr_NEW_DARKROOM))
29306 {
29307 if(get_qr(qr_FADE))
29308 {
29309 interpolatedfade();
29310 }
29311 else
29312 {
29313 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
29314 }
29315
29316 darkroom=naturaldark=true;
29317 }
29318 else
29319 {
29320 darkroom=naturaldark=false;
29321 }
29322
29323
29324 //Move Player's coordinates
29325 Hero.x = (zfix)wx;
29326 Hero.y = (zfix)wy;
29327 //set his dir
29328 switch(heroFacesDir)
29329 {
29330 case up:
29331 case down:
29332 case left:
29333 case right:
29334 Hero.dir = heroFacesDir;
29335 break;
29336 default:
29337 Hero.dir=down;
29338 if((int32_t)Hero.x==(zfix)0)
29339 {
29340 Hero.dir=right;
29341 }
29342 if((int32_t)Hero.x==(zfix)240)
29343 {
29344 Hero.dir=left;
29345 }
29346
29347 if((int32_t)Hero.y==(zfix)0)
29348 {
29349 Hero.dir=down;
29350 }
29351
29352 if((int32_t)Hero.y==(zfix)160)
29353 {
29354 Hero.dir=up;
29355 }
29356 }
29357
29358 if(dlevel)
29359 {
29360 // reset enemy kill counts
29361 for(int32_t i=0; i<128; i++)
29362 {
29363 game->guys[(currmap*MAPSCRSNORMAL)+i] = 0;
29364 game->maps[(currmap*MAPSCRSNORMAL)+i] &= ~mTMPNORET;
29365 }
29366 }
29367
29368 markBmap(Hero.dir^1);
29369 //preloaded freeform combos
29370 ffscript_engine(true);
29371 Hero.reset_hookshot();
29372
29373 if(isdungeon())
29374 {
29375 openscreen();
29376 if(get_er(er_SHORTDGNWALK)==0 && get_qr(qr_SHORTDGNWALK)==0)
29377 Hero.stepforward(Hero.diagonalMovement?11:12, false);
29378 else
29379 // Didn't walk as far pre-1.93, and some quests depend on that
29380 Hero.stepforward(8, false);
29381 }
29382 else
29383 {
29384 openscreen();
29385 }
29386
29387 show_subscreen_life=true;
29388 show_subscreen_numbers=true;
29389 Play_Level_Music();
29390 currcset=DMaps[currdmap].color;
29391 dointro();
29392 Hero.set_respawn_point();
29393 Hero.trySideviewLadder();
29394
29395 for(int32_t i=0; i<6; i++)
29396 visited[i]=-1;
29397
29398 //last_entr_scr = scrID;
29399 //last_entr_dmap = dmapID;
29400
29401 break;
29402
29403 }
29404 case wtSCROLL: // scrolling warp
29405 {
29406 int32_t c = DMaps[currdmap].color;
29407 scrolling_map = currmap;
29408 currmap = DMaps[dmapID].map;
29409 update_subscreens(dmapID);
29410
29411 dlevel = DMaps[dmapID].level;
29412 //check if Hero has the map for the new location before updating the subscreen. ? -Z
29413 //This works only in one direction, if Hero had a map, to not having one.
29414 //If Hero does not have a map, and warps somewhere where he does, then the map still briefly shows.
29415 update_subscreens(dmapID);
29416
29417 // if ( has_item(itype_map, dlevel) )
29418 // {
29419 // //Blank the map during an intra-dmap scrolling warp.
29420 // dlevel = -1; //a hack for the minimap. This works!! -Z
29421 // }
29422
29423 // fix the scrolling direction, if it was a tile or instant warp
29424 Hero.sdir = vbound(Hero.dir,0,3);
29425
29426
29427 Hero.scrollscr(Hero.sdir, scrID+DMaps[dmapID].xoff, dmapID);
29428 bool changedlevel = false;
29429 bool changeddmap = false;
29430 if(currdmap != dmapID)
29431 {
29432 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
29433 changeddmap = true;
29434 }
29435 if(dlevel != DMaps[dmapID].level)
29436 {
29437 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
29438 changedlevel = true;
29439 }
29440 dlevel = DMaps[dmapID].level;
29441 currdmap = dmapID;
29442 if(changeddmap)
29443 {
29444 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
29445 }
29446 if(changedlevel)
29447 {
29448 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
29449 }
29450
29451 Hero.reset_hookshot();
29452
29453 if(!intradmap)
29454 {
29455 currdmap = dmapID;
29456 dlevel = DMaps[currdmap].level;
29457 homescr = currscr = scrID + DMaps[dmapID].xoff;
29458 init_dmap();
29459
29460
29461 if(((wx>0||wy>0)||(get_qr(qr_WARPSIGNOREARRIVALPOINT)))&&(!get_qr(qr_NOSCROLLCONTINUE))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
29462 {
29463 if(dlevel)
29464 {
29465 lastentrance = currscr;
29466 }
29467 else
29468 {
29469 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
29470 }
29471
29472 lastentrance_dmap = dmapID;
29473 }
29474 }
29475
29476 if(DMaps[currdmap].color != c)
29477 {
29478 lighting(false, true);
29479 }
29480
29481 Play_Level_Music();
29482 currcset=DMaps[currdmap].color;
29483 dointro();
29484 break;
29485 }
29486 //Cannot use these types with scripts, or with strings.
29487 case wtCAVE:
29488 case wtPASS:
29489 case wtWHISTLE:
29490 default:
29491 {
29492 Z_scripterrlog("Invalid warp type (%d) supplied to Hero->WarpEx()!. Cannot warp!!\n", warpType);
29493 Hero.is_warping = false;
29494 return false;
29495 }
29496 }
29497 // Stop Hero from drowning!
29498
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(Hero.getAction()==drowning)
29499 {
29500 Hero.drownclk=0;
29501 Hero.setAction(none); FFCore.setHeroAction(none);
29502 }
29503
29504 // But keep him swimming if he ought to be!
29505
3/8
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
16 if(Hero.getAction()!=rafting && iswaterex(MAPCOMBO((int32_t)Hero.x,(int32_t)Hero.y+8), currmap, currscr, -1, Hero.x, Hero.y+8, true) && (_walkflag((int32_t)Hero.x,(int32_t)Hero.y+8,0) || get_qr(qr_DROWN))
29506 && (current_item(itype_flippers)) && (Hero.getAction()!=inwind))
29507 {
29508 Hero.hopclk=0xFF;
29509 if (isSideViewHero() && get_qr(qr_SIDESWIM)) {Hero.setAction(sideswimming); FFCore.setHeroAction(sideswimming);}
29510 else {Hero.setAction(swimming); FFCore.setHeroAction(swimming);}
29511 }
29512
29513 16 newscr_clk=frame;
29514 16 activated_timed_warp=false;
29515 16 eat_buttons();
29516
29517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(warpType!=wtIWARP) { Hero.attackclk=0; }
29518
29519 16 Hero.didstuff=0;
29520 16 Hero.usecounts.clear();
29521 16 map_bkgsfx(true);
29522 16 loadside=Hero.dir^1;
29523 16 whistleclk=-1;
29524
29525
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 if(((int32_t)Hero.z>0 || (int32_t)Hero.fakez>0) && isSideViewHero())
29526 {
29527 Hero.y-=Hero.z;
29528 Hero.y-=Hero.fakez;
29529 Hero.z=0;
29530 Hero.fakez=0;
29531 }
29532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 else if(!isSideViewHero())
29533 {
29534 16 Hero.fall=0;
29535 16 Hero.fakefall=0;
29536 16 }
29537
29538 // If warping between top-down and sideview screens,
29539 // fix enemies that are carried over by Full Screen Warp
29540 16 const bool tmpscr_is_sideview = isSideViewGravity();
29541
29542
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 if(!wasSideview && tmpscr_is_sideview)
29543 {
29544 for(int32_t i=0; i<guys.Count(); i++)
29545 {
29546 if(guys.spr(i)->z > 0)
29547 {
29548 guys.spr(i)->y -= guys.spr(i)->z;
29549 guys.spr(i)->z = 0;
29550 }
29551
29552 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
29553 guys.spr(i)->yofs += 2;
29554 }
29555 }
29556
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 else if(wasSideview && !tmpscr_is_sideview)
29557 {
29558 for(int32_t i=0; i<guys.Count(); i++)
29559 {
29560 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
29561 guys.spr(i)->yofs -= 2;
29562 }
29563 }
29564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( warpType == wtEXIT )
29565 {
29566 //game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
29567 game->set_continue_scrn(scrID);
29568 game->set_continue_dmap(dmapID);
29569 lastentrance = scrID;
29570 //zprint("Setting Last Entrance to: %d\n", scrID);
29571 //zprint("lastentrance = %d\n",lastentrance);
29572 lastentrance_dmap = dmapID;
29573 //zprint("Setting Last Entrance DMap to: %d\n", dmapID);
29574 //zprint("lastentrance_dmap = %d\n",lastentrance_dmap);
29575 //lastentrance_dmap = currdmap;
29576 //lastentrance = game->get_continue_scrn();
29577 }
29578 else
29579 {
29580
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( (warpFlags&warpFlagSETENTRANCESCREEN) ) lastentrance = scrID;
29581
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( (warpFlags&warpFlagSETENTRANCEDMAP) ) lastentrance_dmap = dmapID;
29582
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( (warpFlags&warpFlagSETCONTINUESCREEN) ) game->set_continue_scrn(scrID);
29583
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( (warpFlags&warpFlagSETCONTINUEDMAP) ) game->set_continue_dmap(dmapID);
29584
29585
29586 }
29587
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tmpscr->flags4&fAUTOSAVE)
29588 {
29589 save_game(true,0);
29590 }
29591
29592
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tmpscr->flags6&fCONTINUEHERE)
29593 {
29594 lastentrance_dmap = currdmap;
29595 lastentrance = homescr;
29596 }
29597
29598 16 update_subscreens();
29599 16 verifyBothWeapons();
29600 32 Z_eventlog("Warped to DMap %d: %s, screen %d, via %s.\n", currdmap, DMaps[currdmap].name,currscr,
29601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
32 warpType==wtEXIT ? "Entrance/Exit" :
29602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 warpType==wtSCROLL ? "Scrolling Warp" :
29603 16 warpType==wtNOWARP ? "Cancel Warp" :
29604 "Insta-Warp");
29605
29606 16 eventlog_mapflags();
29607
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if (((warpFlags&warpFlagDONTRESTARTDMAPSCRIPT) != 0) == (get_qr(qr_SCRIPT_WARPS_DMAP_SCRIPT_TOGGLE) != 0)|| olddmap != currdmap) //Changed DMaps, or needs to reset the script
29608 {
29609 16 FFScript::deallocateAllArrays(ScriptType::DMap, olddmap);
29610 16 initZScriptDMapScripts();
29611 16 }
29612 16 Hero.is_warping = false;
29613
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!get_qr(qr_SCROLLWARP_NO_RESET_FRAME))
29614 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
29615 16 return true;
29616 16 }
29617
29618 void FFScript::do_adjustvolume(const bool v)
29619 {
29620 if (get_qr(qr_OLD_SCRIPT_VOLUME))
29621 {
29622 int32_t perc = (SH::get_arg(sarg1, v) / 10000);
29623 float pct = perc / 100.0;
29624 // zprint("pct is: %f\n",pct);
29625 float temp_midi = 0;
29626 float temp_digi = 0;
29627 float temp_mus = 0;
29628 if (!(coreflags & FFCORE_SCRIPTED_MIDI_VOLUME))
29629 {
29630 // zprint("FFCORE_SCRIPTED_MIDI_VOLUME: wasn't set\n");
29631 temp_midi = do_getMIDI_volume();
29632 // zprint("temp_midi is %f\n", temp_midi);
29633 usr_midi_volume = do_getMIDI_volume();
29634 // zprint("usr_midi_volume stored as %d\n", usr_midi_volume);
29635 SetFFEngineFlag(FFCORE_SCRIPTED_MIDI_VOLUME, true);
29636 }
29637 else
29638 {
29639 temp_midi = (float)usr_midi_volume;
29640 }
29641 if (!(coreflags & FFCORE_SCRIPTED_DIGI_VOLUME))
29642 {
29643 temp_digi = do_getDIGI_volume();
29644 usr_digi_volume = do_getDIGI_volume();
29645 // zprint("usr_music_volume stored as %d\n", usr_digi_volume);
29646 SetFFEngineFlag(FFCORE_SCRIPTED_DIGI_VOLUME, true);
29647 }
29648 else
29649 {
29650 temp_digi = (float)usr_digi_volume;
29651 }
29652 if (!(coreflags & FFCORE_SCRIPTED_MUSIC_VOLUME))
29653 {
29654 temp_mus = do_getMusic_volume();
29655 usr_music_volume = do_getMusic_volume();
29656 // zprint("usr_music_volume stored as %d\n", usr_music_volume);
29657 SetFFEngineFlag(FFCORE_SCRIPTED_MUSIC_VOLUME, true);
29658 }
29659 else
29660 {
29661 temp_mus = (float)usr_music_volume;
29662 }
29663
29664 temp_midi *= pct;
29665 temp_digi *= pct;
29666 temp_mus *= pct;
29667 // zprint("temp_midi is: %f\n",temp_midi);
29668 // zprint("temp_digi is: %f\n",temp_digi);
29669 // zprint("temp_mus is: %f\n",temp_mus);
29670 do_setMIDI_volume((int32_t)temp_midi);
29671 do_setDIGI_volume((int32_t)temp_digi);
29672 do_setMusic_volume((int32_t)temp_mus);
29673 }
29674 else
29675 {
29676 int32_t perc = SH::get_arg(sarg1, v);
29677 FFCore.usr_music_volume = vbound(perc, 0, 10000 * 100);
29678
29679 if (zcmusic != NULL)
29680 {
29681 if (zcmusic->playing != ZCM_STOPPED)
29682 {
29683 int32_t temp_volume = emusic_volume;
29684 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
29685 temp_volume = (emusic_volume * FFCore.usr_music_volume) / 10000 / 100;
29686 temp_volume = (temp_volume * zcmusic->fadevolume) / 10000;
29687 zcmusic_play(zcmusic, temp_volume);
29688 return;
29689 }
29690 }
29691 else if (currmidi > -1)
29692 {
29693 jukebox(currmidi);
29694 master_volume(digi_volume, midi_volume);
29695 }
29696 }
29697 }
29698
29699 void FFScript::do_adjustsfxvolume(const bool v)
29700 {
29701 if (get_qr(qr_OLD_SCRIPT_VOLUME))
29702 {
29703 int32_t perc = (SH::get_arg(sarg1, v) / 10000);
29704 float pct = perc / 100.0;
29705 float temp_sfx = 0;
29706 if (!(coreflags & FFCORE_SCRIPTED_SFX_VOLUME))
29707 {
29708 temp_sfx = do_getSFX_volume();
29709 usr_sfx_volume = (int32_t)temp_sfx;
29710 // zprint("usr_sfx_volume stored as %d\n", usr_sfx_volume);
29711 SetFFEngineFlag(FFCORE_SCRIPTED_SFX_VOLUME, true);
29712 }
29713 else
29714 {
29715 temp_sfx = (float)usr_sfx_volume;
29716 }
29717 temp_sfx *= pct;
29718 do_setSFX_volume((int32_t)temp_sfx);
29719 }
29720 else
29721 {
29722 int32_t perc = SH::get_arg(sarg1, v);
29723 FFCore.usr_sfx_volume = vbound(perc, 0, 10000 * 100);
29724 }
29725 }
29726
29727
29728 63813 void do_midi(bool v)
29729 {
29730 63813 int32_t MIDI = SH::get_arg(sarg1, v) / 10000;
29731
29732
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 63776 times.
63813 if(MIDI == 0)
29733 37 music_stop();
29734 else
29735 63776 jukebox(MIDI + (ZC_MIDI_COUNT - 1));
29736 63813 }
29737
29738
29739 void stop_sfx(const bool v)
29740 {
29741 int32_t ID = SH::get_arg(sarg1, v) / 10000;
29742 int32_t sfx = (int32_t)ID;
29743 if(BC::checkSFXID(ID, "Game->EndSound") != SH::_NoError)
29744 return;
29745 stop_sfx(sfx);
29746 }
29747
29748 void pause_sfx(const bool v)
29749 {
29750 int32_t ID = SH::get_arg(sarg1, v) / 10000;
29751 int32_t sfx = (int32_t)ID;
29752 if(BC::checkSFXID(ID, "Game->PauseSound") != SH::_NoError)
29753 return;
29754 pause_sfx(sfx);
29755 }
29756
29757 void resume_sfx(const bool v)
29758 {
29759 int32_t ID = SH::get_arg(sarg1, v) / 10000;
29760 int32_t sfx = (int32_t)ID;
29761 if(BC::checkSFXID(ID, "Game->ResumeSound") != SH::_NoError)
29762 return;
29763 resume_sfx(sfx);
29764 }
29765
29766
29767
29768 79 void do_enh_music(bool v)
29769 {
29770 79 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
29771 79 int32_t track = (SH::get_arg(sarg2, v) / 10000)-1;
29772
29773
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(arrayptr == 0)
29774 music_stop();
29775 else // Pointer to a string..
29776 {
29777 79 string filename_str;
29778 char filename_char[256];
29779 bool ret;
29780
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 ArrayH::getString(arrayptr, filename_str, 256);
29781 79 strncpy(filename_char, filename_str.c_str(), 255);
29782 79 filename_char[255]='\0';
29783
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 ret=try_zcmusic(filename_char, track, -1000);
29784
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 set_register(sarg2, ret ? 10000 : 0);
29785 79 }
29786 79 }
29787
29788 void do_enh_music_crossfade()
29789 {
29790 int32_t arrayptr = SH::read_stack(ri->sp + 5) / 10000;
29791 int32_t track = SH::read_stack(ri->sp + 4) / 10000;
29792 int32_t fadeoutframes = zc_max(SH::read_stack(ri->sp + 3) / 10000, 0);
29793 int32_t fadeinframes = zc_max(SH::read_stack(ri->sp + 2) / 10000, 0);
29794 int32_t fademiddleframes = SH::read_stack(ri->sp + 1) / 10000;
29795 int32_t startpos = SH::read_stack(ri->sp);
29796
29797 if (arrayptr == 0)
29798 {
29799 bool ret = FFCore.play_enh_music_crossfade(NULL, track, fadeoutframes, fadeinframes, fademiddleframes, startpos);
29800 ri->d[rEXP1] = ret ? 10000 : 0;
29801 }
29802 else
29803 {
29804 string filename_str;
29805 char filename_char[256];
29806 ArrayH::getString(arrayptr, filename_str, 256);
29807 strncpy(filename_char, filename_str.c_str(), 255);
29808 filename_char[255] = '\0';
29809 bool ret = FFCore.play_enh_music_crossfade(filename_char, track, fadeoutframes, fadeinframes, fademiddleframes, startpos, true);
29810 ri->d[rEXP1] = ret ? 10000 : 0;
29811 }
29812 }
29813
29814 bool FFScript::play_enh_music_crossfade(char* name, int32_t track, int32_t fadeinframes, int32_t fadeoutframes, int32_t fademiddleframes, int32_t startpos, bool revertonfail)
29815 {
29816 double fadeoutpct = 1.0;
29817 // If there was an old fade going, use that as a multiplier for the new fade out
29818 if (zcmixer->newtrack != NULL)
29819 {
29820 fadeoutpct = double(zcmixer->newtrack->fadevolume) / 10000.0;
29821 }
29822
29823 ZCMUSIC* oldold = zcmixer->oldtrack;
29824 bool ret = false;
29825
29826 if (name == NULL)
29827 {
29828 // Pass currently playing music off to the mixer
29829 zcmixer->oldtrack = zcmusic;
29830 // Do not play new music
29831 zcmusic = NULL;
29832 zcmixer->newtrack = NULL;
29833
29834 zcmixer->fadeinframes = fadeinframes;
29835 zcmixer->fadeinmaxframes = fadeinframes;
29836 zcmixer->fadeoutframes = zc_max(fadeoutframes * fadeoutpct, 1);
29837 zcmixer->fadeoutmaxframes = fadeoutframes;
29838 if (fademiddleframes < 0)
29839 {
29840 zcmixer->fadeindelay = 0;
29841 zcmixer->fadeoutdelay = -fademiddleframes;
29842 }
29843 else
29844 {
29845 zcmixer->fadeindelay = fademiddleframes;
29846 zcmixer->fadeoutdelay = 0;
29847 }
29848 if (zcmixer->oldtrack != NULL)
29849 zcmixer->oldtrack->fadevolume = 10000;
29850 if (zcmixer->newtrack != NULL)
29851 zcmixer->newtrack->fadevolume = 0;
29852 }
29853 else // Pointer to a string..
29854 {
29855 // Pass currently playing music to the mixer
29856 zcmixer->oldtrack = zcmusic;
29857 zcmusic = NULL;
29858 zcmixer->newtrack = NULL;
29859
29860 ret = try_zcmusic(name, track, -1000, fadeoutframes);
29861 // If new music was found
29862 if (ret)
29863 {
29864 // New music fades in
29865 if (zcmusic != NULL)
29866 zcmusic->fadevolume = 0;
29867
29868 zcmixer->newtrack = zcmusic;
29869 zcmixer->fadeinframes = fadeinframes;
29870 zcmixer->fadeinmaxframes = fadeinframes;
29871 zcmixer->fadeoutframes = zc_max(fadeoutframes * fadeoutpct, 1);
29872 zcmixer->fadeoutmaxframes = fadeoutframes;
29873 if (fademiddleframes < 0)
29874 {
29875 zcmixer->fadeindelay = 0;
29876 zcmixer->fadeoutdelay = -fademiddleframes;
29877 }
29878 else
29879 {
29880 zcmixer->fadeindelay = fademiddleframes;
29881 zcmixer->fadeoutdelay = 0;
29882 }
29883 if (startpos > 0)
29884 zcmusic_set_curpos(zcmixer->newtrack, startpos);
29885 if (zcmixer->oldtrack != NULL)
29886 zcmixer->oldtrack->fadevolume = 10000;
29887 if (zcmixer->newtrack != NULL)
29888 zcmixer->newtrack->fadevolume = 0;
29889 }
29890 else if(revertonfail)
29891 {
29892 // Switch back to the old music
29893 zcmusic = zcmixer->oldtrack;
29894 zcmixer->newtrack = NULL;
29895 zcmixer->oldtrack = NULL;
29896 }
29897 }
29898
29899 // If there was already an old track playing, stop it
29900 if (oldold != NULL)
29901 {
29902 // Don't allow it to null both tracks if running twice in a row
29903 if (zcmixer->newtrack == NULL && zcmixer->oldtrack == NULL)
29904 {
29905 zcmixer->oldtrack = oldold;
29906
29907 if (oldold->fadeoutframes > 0)
29908 {
29909 zcmixer->fadeoutframes = zc_max(oldold->fadeoutframes * fadeoutpct, 1);
29910 zcmixer->fadeoutmaxframes = oldold->fadeoutframes;
29911 if (zcmixer->oldtrack != NULL)
29912 zcmixer->oldtrack->fadevolume = 10000;
29913 oldold->fadeoutframes = 0;
29914 }
29915 }
29916 else
29917 {
29918 zcmusic_stop(oldold);
29919 zcmusic_unload_file(oldold);
29920 oldold = NULL;
29921 }
29922 }
29923
29924 return ret;
29925 }
29926
29927 bool FFScript::doing_dmap_enh_music(int32_t dm)
29928 {
29929 if (DMaps[dm].tmusic[0] != 0)
29930 {
29931 if (zcmusic != NULL)
29932 {
29933 if (strcmp(zcmusic->filename, DMaps[dm].tmusic) == 0)
29934 {
29935 switch (zcmusic_get_type(zcmusic))
29936 {
29937 case ZCMF_OGG:
29938 case ZCMF_MP3:
29939 return true;
29940 case ZCMF_DUH:
29941 case ZCMF_GME:
29942 if (zcmusic->track == DMaps[dm].tmusictrack)
29943 {
29944 return true;
29945 }
29946 }
29947 }
29948 }
29949 }
29950 return false;
29951 }
29952
29953 17605 bool FFScript::can_dmap_change_music(int32_t dm)
29954 {
29955
1/4
✓ Branch 0 taken 17605 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17605 switch (music_update_cond)
29956 {
29957 case MUSIC_UPDATE_SCREEN:
29958 17605 return true;
29959 case MUSIC_UPDATE_DMAP:
29960 return dm != -1 && dm != currdmap;
29961 case MUSIC_UPDATE_LEVEL:
29962 return dm != -1 && DMaps[dm].level != DMaps[currdmap].level;
29963 }
29964 return false;
29965 17605 }
29966
29967 void FFScript::do_set_music_position(const bool v)
29968 {
29969 int32_t newposition = SH::get_arg(sarg1, v);
29970
29971 set_zcmusicpos(newposition);
29972 }
29973
29974 void FFScript::do_get_music_position()
29975 {
29976 int32_t pos = get_zcmusicpos();
29977
29978 // TODO: record results for replays
29979
29980 set_register(sarg1, pos);
29981 }
29982
29983 void FFScript::do_set_music_speed(const bool v)
29984 {
29985 int32_t newspeed = SH::get_arg(sarg1, v);
29986 set_zcmusicspeed(newspeed);
29987 }
29988
29989 void FFScript::do_get_music_length()
29990 {
29991 int32_t len = get_zcmusiclen();
29992 set_register(sarg1, len);
29993 }
29994
29995 void FFScript::do_set_music_loop()
29996 {
29997 double start = (get_register(sarg1) / 10000);
29998 double end = (get_register(sarg2) / 10000);
29999
30000 set_zcmusicloop(start, end);
30001 }
30002
30003 100 void do_get_enh_music_filename(const bool v)
30004 {
30005 100 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30006 100 int32_t arrayptr = get_register(sarg2) / 10000;
30007
30008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(BC::checkDMapID(ID, "Game->GetDMapMusicFilename") != SH::_NoError)
30009 return;
30010
30011
3/6
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
100 if(ArrayH::setArray(arrayptr, string(DMaps[ID].tmusic)) == SH::_Overflow)
30012 Z_scripterrlog("Array supplied to 'Game->GetDMapMusicFilename' not large enough\n");
30013 100 }
30014
30015 5 void do_get_enh_music_track(const bool v)
30016 {
30017 5 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30018
30019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(BC::checkDMapID(ID, "Game->GetDMapMusicTrack") != SH::_NoError)
30020 return;
30021
30022 5 set_register(sarg1, (DMaps[ID].tmusictrack+1)*10000);
30023 5 }
30024
30025 3750 void do_set_dmap_enh_music(const bool v)
30026 {
30027 3750 int32_t ID = SH::read_stack(ri->sp + 2) / 10000;
30028 3750 int32_t arrayptr = SH::read_stack(ri->sp + 1) / 10000;
30029 3750 int32_t track = (SH::read_stack(ri->sp + 0) / 10000)-1;
30030 3750 string filename_str;
30031
30032
2/4
✓ Branch 0 taken 3750 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3750 times.
✗ Branch 3 not taken.
3750 if(BC::checkDMapID(ID, "Game->SetDMapEnhancedMusic") != SH::_NoError)
30033 return;
30034
30035
1/2
✓ Branch 0 taken 3750 times.
✗ Branch 1 not taken.
3750 ArrayH::getString(arrayptr, filename_str, 56);
30036 3750 strncpy(DMaps[ID].tmusic, filename_str.c_str(), 55);
30037 3750 DMaps[ID].tmusic[55]='\0';
30038 3750 DMaps[ID].tmusictrack=track;
30039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3750 times.
3750 }
30040
30041
30042
30043
30044
30045
30046 ///----------------------------------------------------------------------------------------------------//
30047 //Array & string related
30048
30049 294114413 void do_arraysize()
30050 {
30051 294114413 int32_t arrayptr = get_register(sarg1) / 10000;
30052 294114413 ri->d[rEXP1] = ArrayH::getSize(arrayptr) * 10000;
30053 294114413 }
30054
30055 void do_tobyte()
30056 {
30057 int32_t b1 = get_register(sarg1) / 10000;
30058 byte b2 = b1;
30059 set_register(sarg1, b2 * 10000);
30060 }
30061
30062 void do_tosignedbyte()
30063 {
30064 int32_t b1 = get_register(sarg1) / 10000;
30065 signed char b2 = b1;
30066 set_register(sarg1, b2 * 10000);
30067 }
30068
30069 void do_tointeger()
30070 {
30071 int32_t b1 = get_register(sarg1) / 10000;
30072 set_register(sarg1, b1 * 10000);
30073 }
30074
30075 void do_floor()
30076 {
30077 double b1 = get_register(sarg1) / 10000.0;
30078 int32_t b2 = floor(b1);
30079 set_register(sarg1, b2 * 10000);
30080 }
30081
30082 void do_ceiling()
30083 {
30084 double b1 = get_register(sarg1) / 10000.0;
30085 int32_t b2 = ceil(b1);
30086 set_register(sarg1, b2 * 10000);
30087 }
30088
30089 void do_toword()
30090 {
30091 int32_t b1 = get_register(sarg1) / 10000;
30092 word b2 = b1;
30093 set_register(sarg1, b2 * 10000);
30094 }
30095
30096 void do_toshort()
30097 {
30098 int32_t b1 = get_register(sarg1) / 10000;
30099 int16_t b2 = b1;
30100 set_register(sarg1, b2 * 10000);
30101 }
30102
30103 10 void do_getsavename()
30104 {
30105 10 int32_t arrayptr = get_register(sarg1) / 10000;
30106
30107
3/6
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 if(ArrayH::setArray(arrayptr, string(game->get_name())) == SH::_Overflow)
30108 Z_scripterrlog("Array supplied to 'Game->GetSaveName' not large enough\n");
30109 10 }
30110
30111 void do_setsavename()
30112 {
30113 int32_t arrayptr = get_register(sarg1) / 10000;
30114
30115 string str;
30116 ArrayH::getString(arrayptr, str);
30117 byte j;
30118
30119 for(j = 0; str[j] != '\0'; j++)
30120 {
30121 if(j >= 8)
30122 {
30123 Z_scripterrlog("String supplied to 'Game->GetSaveName' too large\n");
30124 break;
30125 }
30126
30127 game->get_name_mutable()[j] = str[j];
30128 }
30129
30130 game->get_name_mutable()[j] = '\0';
30131 }
30132
30133 3666 void do_getmessage(const bool v)
30134 {
30135 3666 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30136 3666 int32_t arrayptr = get_register(sarg2) / 10000;
30137
30138
1/2
✓ Branch 0 taken 3666 times.
✗ Branch 1 not taken.
3666 if(BC::checkMessage(ID, "Game->GetMessage") != SH::_NoError)
30139 return;
30140
30141
2/2
✓ Branch 0 taken 3618 times.
✓ Branch 1 taken 48 times.
3666 if(ArrayH::setArray(arrayptr, MsgStrings[ID].s) == SH::_Overflow)
30142 48 Z_scripterrlog("Array supplied to 'Game->GetMessage' not large enough\n");
30143 3666 }
30144
30145
30146
30147 void do_setmessage(const bool v)
30148 {
30149 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30150 int32_t arrayptr = get_register(sarg2) / 10000;
30151
30152 if(BC::checkMessage(ID, "Game->SetMessage") != SH::_NoError)
30153 return;
30154
30155 ArrayH::getString(arrayptr, MsgStrings[ID].s, MSG_NEW_SIZE);
30156 }
30157
30158
30159 void do_getdmapname(const bool v)
30160 {
30161 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30162 int32_t arrayptr = get_register(sarg2) / 10000;
30163
30164 if(BC::checkDMapID(ID, "Game->GetDMapName") != SH::_NoError)
30165 return;
30166
30167 if(ArrayH::setArray(arrayptr, string(DMaps[ID].name)) == SH::_Overflow)
30168 Z_scripterrlog("Array supplied to 'Game->GetDMapName' not large enough\n");
30169 }
30170
30171 void do_setdmapname(const bool v)
30172 {
30173 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30174 int32_t arrayptr = get_register(sarg2) / 10000;
30175
30176 string filename_str;
30177
30178 if(BC::checkDMapID(ID, "Game->Game->SetDMapName") != SH::_NoError)
30179 return;
30180
30181 ArrayH::getString(arrayptr, filename_str, 22);
30182 strncpy(DMaps[ID].name, filename_str.c_str(), 21);
30183 DMaps[ID].name[20]='\0';
30184 }
30185
30186 701 void do_getdmaptitle(const bool v)
30187 {
30188 701 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30189 701 int32_t arrayptr = get_register(sarg2) / 10000;
30190
30191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 701 times.
701 if(BC::checkDMapID(ID, "Game->GetDMapTitle") != SH::_NoError)
30192 return;
30193
30194
3/6
✓ Branch 0 taken 701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 701 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 701 times.
✗ Branch 5 not taken.
701 if(ArrayH::setArray(arrayptr, string(DMaps[ID].title)) == SH::_Overflow)
30195 Z_scripterrlog("Array supplied to 'Game->GetDMapTitle' not large enough\n");
30196 701 }
30197
30198
30199 void do_setdmaptitle(const bool v)
30200 {
30201 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30202 int32_t arrayptr = get_register(sarg2) / 10000;
30203 string filename_str;
30204
30205 if(BC::checkDMapID(ID, "Game->Game->SetDMapTitle") != SH::_NoError)
30206 return;
30207
30208 ArrayH::getString(arrayptr, filename_str, 21);
30209 strncpy(DMaps[ID].title, filename_str.c_str(), 20);
30210 DMaps[ID].title[20]='\0';
30211 }
30212
30213 void do_getdmapintro(const bool v)
30214 {
30215 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30216 int32_t arrayptr = get_register(sarg2) / 10000;
30217
30218 if(BC::checkDMapID(ID, "Game->GetDMapIntro") != SH::_NoError)
30219 return;
30220
30221 if(ArrayH::setArray(arrayptr, string(DMaps[ID].intro)) == SH::_Overflow)
30222 Z_scripterrlog("Array supplied to 'Game->GetDMapIntro' not large enough\n");
30223 }
30224
30225
30226 void do_setdmapintro(const bool v)
30227 {
30228 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30229 int32_t arrayptr = get_register(sarg2) / 10000;
30230 string filename_str;
30231
30232 if(BC::checkDMapID(ID, "Game->Game->SetDMapIntro") != SH::_NoError)
30233 return;
30234
30235 ArrayH::getString(arrayptr, filename_str, 73);
30236 strncpy(DMaps[ID].intro, filename_str.c_str(), 72);
30237 DMaps[ID].intro[72]='\0';
30238 }
30239
30240 //Set npc and item names t.b.a. -Z
30241
30242 2691 void do_getitemname()
30243 {
30244 2691 int32_t arrayptr = get_register(sarg1) / 10000;
30245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2691 times.
2691 if(unsigned(ri->idata) >= MAXITEMS)
30246 {
30247 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
30248 return;
30249 }
30250
30251
3/6
✓ Branch 0 taken 2691 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2691 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2691 times.
✗ Branch 5 not taken.
2691 if(ArrayH::setArray(arrayptr, item_string[ri->idata]) == SH::_Overflow)
30252 Z_scripterrlog("Array supplied to 'itemdata->GetName' not large enough\n");
30253 2691 }
30254
30255 void do_getnpcname()
30256 {
30257 int32_t arrayptr = get_register(sarg1) / 10000;
30258
30259 if(GuyH::loadNPC(ri->guyref, "npc->GetName") != SH::_NoError)
30260 return;
30261
30262 word ID = (GuyH::getNPC()->id & 0xFFF);
30263
30264 if(ArrayH::setArray(arrayptr, guy_string[ID]) == SH::_Overflow)
30265 Z_scripterrlog("Array supplied to 'npc->GetName' not large enough\n");
30266 }
30267
30268 //npcdata->GetName
30269 void FFScript::do_getnpcdata_getname()
30270 {
30271 int32_t arrayptr = get_register(sarg1) / 10000;
30272 int32_t npc_id = ri->npcdataref;
30273 if((unsigned)npc_id > 511)
30274 {
30275 Z_scripterrlog("Invalid npc ID (%d) passed to npcdata->GetName().\n", npc_id);
30276 return;
30277 }
30278
30279 if(ArrayH::setArray(arrayptr, guy_string[npc_id]) == SH::_Overflow)
30280 Z_scripterrlog("Array supplied to 'npcdata->GetName()' not large enough\n");
30281 }
30282
30283 227724 void do_getffcscript()
30284 {
30285 227724 int32_t arrayptr = get_register(sarg1) / 10000;
30286 227724 string name;
30287 227724 int32_t num=-1;
30288
1/2
✓ Branch 0 taken 227724 times.
✗ Branch 1 not taken.
227724 ArrayH::getString(arrayptr, name, 256); // What's the limit on name length?
30289
30290
2/2
✓ Branch 0 taken 116286088 times.
✓ Branch 1 taken 227034 times.
116513122 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
30291 {
30292
3/4
✓ Branch 0 taken 116286088 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116285398 times.
✓ Branch 3 taken 690 times.
116286088 if(strcmp(name.c_str(), ffcmap[i].scriptname.c_str())==0)
30293 {
30294 690 num=i+1;
30295 690 break;
30296 }
30297 116285398 }
30298
30299
1/2
✓ Branch 0 taken 227724 times.
✗ Branch 1 not taken.
227724 set_register(sarg1, num * 10000);
30300 227724 }
30301
30302 void do_npc_hero_in_range()
30303 {
30304 int32_t dist = get_register(sarg1) / 10000;
30305 if(GuyH::loadNPC(ri->guyref, "npc->LinedUp()") == SH::_NoError)
30306 {
30307 bool in_range = GuyH::getNPC()->HeroInRange(dist);
30308 set_register(sarg1, 0);
30309 }
30310 else set_register(sarg1, 0);
30311 }
30312
30313 80 void do_getitemscript()
30314 {
30315 80 int32_t arrayptr = get_register(sarg1) / 10000;
30316 80 string name;
30317 80 int32_t num=-1;
30318
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 ArrayH::getString(arrayptr, name, 256); // What's the limit on name length?
30319
30320
1/2
✓ Branch 0 taken 2360 times.
✗ Branch 1 not taken.
2360 for(int32_t i=0; i<512; i++)
30321 {
30322
3/4
✓ Branch 0 taken 2360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2280 times.
✓ Branch 3 taken 80 times.
2360 if(strcmp(name.c_str(), itemmap[i].scriptname.c_str())==0)
30323 {
30324 80 num=i+1;
30325 80 break;
30326 }
30327 2280 }
30328
30329
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 set_register(sarg1, num * 10000);
30330 80 }
30331
30332 ///----------------------------------------------------------------------------------------------------//
30333 //Tile Manipulation
30334
30335 16962076 void do_copytile(const bool v, const bool v2)
30336 {
30337 16962076 int32_t tile = SH::get_arg(sarg1, v) / 10000;
30338 16962076 int32_t tile2 = SH::get_arg(sarg2, v2) / 10000;
30339
30340 16962076 copy_tile(newtilebuf, tile, tile2, false);
30341 16962076 }
30342
30343 int32_t FFScript::IsBlankTile(int32_t i)
30344 {
30345 if( ((unsigned)i) > NEWMAXTILES )
30346 {
30347 Z_scripterrlog("Invalid tile ID (%d) passed to Graphics->IsBlankTile[]\n");
30348 return -1;
30349 }
30350
30351 byte *tilestart=newtilebuf[i].data;
30352 qword *di=(qword*)tilestart;
30353 int32_t parts=tilesize(newtilebuf[i].format)>>3;
30354
30355 for(int32_t j=0; j<parts; ++j, ++di)
30356 {
30357 if(*di!=0)
30358 {
30359 return 0;
30360 }
30361 }
30362
30363 return 1;
30364 }
30365
30366 void do_swaptile(const bool v, const bool v2)
30367 {
30368 int32_t tile = SH::get_arg(sarg1, v) / 10000;
30369 int32_t tile2 = SH::get_arg(sarg2, v2) / 10000;
30370
30371 copy_tile(newtilebuf, tile, tile2, true);
30372 }
30373
30374 57032 void do_overlaytile(const bool v, const bool v2)
30375 {
30376 57032 int32_t tile = SH::get_arg(sarg1, v) / 10000;
30377 57032 int32_t tile2 = SH::get_arg(sarg2, v2) / 10000;
30378
30379
2/4
✓ Branch 0 taken 57032 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57032 times.
✗ Branch 3 not taken.
57032 if(BC::checkTile(tile, "OverlayTile") != SH::_NoError ||
30380 57032 BC::checkTile(tile2, "OverlayTile") != SH::_NoError)
30381 return;
30382
30383 //Could add an arg for the CSet or something instead of just passing 0, currently only 8-bit is supported
30384 57032 overlay_tile(newtilebuf, tile, tile2, 0, false);
30385 57032 }
30386
30387 void do_fliprotatetile(const bool v, const bool v2)
30388 {
30389 int32_t tile = SH::get_arg(sarg1, v) / 10000;
30390 int32_t tile2 = SH::get_arg(sarg2, v2) / 10000;
30391
30392 if(BC::checkTile(tile, "FlipRotateTile") != SH::_NoError ||
30393 BC::checkTile(tile2, "FlipRotateTile") != SH::_NoError)
30394 return;
30395
30396 //fliprotatetile
30397 }
30398
30399 void do_settilepixel(const bool v)
30400 {
30401 int32_t tile = SH::get_arg(sarg1, v) / 10000;
30402
30403 if(BC::checkTile(tile, "SetTilePixel") != SH::_NoError)
30404 return;
30405
30406 //settilepixel
30407 }
30408
30409 void do_gettilepixel(const bool v)
30410 {
30411 int32_t tile = SH::get_arg(sarg1, v) / 10000;
30412
30413 if(BC::checkTile(tile, "GetTilePixel") != SH::_NoError)
30414 return;
30415
30416 //gettilepixel
30417 }
30418
30419 void do_shifttile(const bool v, const bool v2)
30420 {
30421 int32_t tile = SH::get_arg(sarg1, v) / 10000;
30422 int32_t tile2 = SH::get_arg(sarg2, v2) / 10000;
30423
30424 if(BC::checkTile(tile, "ShiftTile") != SH::_NoError ||
30425 BC::checkTile(tile2, "ShiftTile") != SH::_NoError)
30426 return;
30427
30428 //shifttile
30429 }
30430
30431 void do_cleartile(const bool v)
30432 {
30433 int32_t tile = SH::get_arg(sarg1, v) / 10000;
30434
30435 if(BC::checkTile(tile, "ClearTile") != SH::_NoError)
30436 return;
30437
30438 reset_tile(newtilebuf, tile, newtilebuf[tile].format);
30439 }
30440
30441 2564 void do_combotile(const bool v)
30442 {
30443 2564 int32_t combo = SH::get_arg(sarg2, v) / 10000;
30444
30445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2564 times.
2564 if(BC::checkCombo(combo, "Game->ComboTile") != SH::_NoError)
30446 return;
30447
30448 2564 set_register(sarg1, combobuf[combo].tile * 10000);
30449 2564 }
30450
30451 94532623 void do_readpod(const bool v)
30452 {
30453 94532623 int32_t indx = SH::get_arg(sarg2, v) / 10000;
30454 94532623 int32_t val = ArrayH::getElement(ri->d[rINDEX] / 10000, indx, can_neg_array);
30455 94532623 set_register(sarg1, val);
30456 94532623 }
30457 63152727 void do_writepod(const bool v1, const bool v2)
30458 {
30459 63152727 int32_t indx = SH::get_arg(sarg1, v1) / 10000;
30460 63152727 int32_t val = SH::get_arg(sarg2, v2);
30461 63152727 ArrayH::setElement(ri->d[rINDEX] / 10000, indx, val, can_neg_array);
30462 63152727 }
30463 241209 void do_writepodstr()
30464 {
30465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 241209 times.
241209 if(!sargstr) return;
30466 241209 auto ptr = get_register(sarg1) / 10000;
30467 241209 ArrayH::setArray(ptr, *sargstr);
30468 241209 }
30469 334 void do_writepodarr()
30470 {
30471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 if(!sargvec) return;
30472 334 auto ptr = get_register(sarg1) / 10000;
30473 334 ArrayH::setArray(ptr, sargvec->size(), sargvec->data(), false);
30474 334 }
30475 int32_t get_object_arr(size_t sz)
30476 {
30477 if(!sz || sz > 214748) return 0;
30478 int32_t free_ptr = 1;
30479 auto it = objectRAM.begin();
30480 if(it != objectRAM.end())
30481 {
30482 if(it->first == 1)
30483 {
30484 for(free_ptr = 2; ; ++free_ptr)
30485 {
30486 if(objectRAM.find(free_ptr) == objectRAM.end())
30487 break;
30488 }
30489 }
30490 }
30491 ZScriptArray arr;
30492 arr.Resize(sz);
30493 objectRAM[free_ptr] = arr;
30494 // auto res = objectRAM.emplace(free_ptr);
30495 // ZScriptArray& arr = res.first->second;
30496 // arr.Resize(sz);
30497
30498 return -free_ptr;
30499 }
30500 void destroy_object_arr(int32_t ptr)
30501 {
30502 if(ptr < 0)
30503 {
30504 auto it = objectRAM.find(-ptr);
30505 if(it != objectRAM.end())
30506 objectRAM.erase(it);
30507 }
30508 }
30509 void do_constructclass(ScriptType type, word script, int32_t i)
30510 {
30511 if(!sargvec) return;
30512
30513 size_t num_vars = sargvec->at(0);
30514 size_t total_vars = num_vars + sargvec->size()-1;
30515 auto destr_pc = ri->d[rEXP1];
30516 dword objref = FFCore.get_free_object(false);
30517
30518 if(user_object* obj = checkObject(objref, true))
30519 {
30520 obj->own(type, i);
30521 obj->owned_vars = num_vars;
30522 for(size_t q = 0; q < total_vars; ++q)
30523 {
30524 if(q < num_vars)
30525 {
30526 obj->data.push_back(0);
30527 }
30528 else
30529 {
30530 size_t sz = sargvec->at(q-num_vars+1);
30531 if(auto id = get_object_arr(sz))
30532 obj->data.push_back(10000*id);
30533 else obj->data.push_back(0); //nullptr
30534 }
30535 }
30536 set_register(sarg1, objref);
30537 ri->thiskey = objref;
30538 obj->prep(destr_pc,type,script,i);
30539 }
30540 else set_register(sarg1, 0);
30541 }
30542
30543 void do_readclass()
30544 {
30545 dword objref = get_register(sarg1);
30546 ri->d[rEXP1] = 0;
30547 int32_t ind = sarg2;
30548 if(user_object* obj = checkObject(objref))
30549 {
30550 if(unsigned(ind) >= obj->data.size())
30551 {
30552 Z_scripterrlog("Script tried to read position '%d' out of bounds on a '%d' size object (%d).", ind, obj->data.size(), objref);
30553 }
30554 else
30555 {
30556 ri->d[rEXP1] = obj->data.at(ind);
30557 }
30558 }
30559 }
30560 void do_writeclass()
30561 {
30562 dword objref = get_register(sarg1);
30563 int32_t ind = sarg2;
30564 if(user_object* obj = checkObject(objref))
30565 {
30566 if(unsigned(ind) >= obj->data.size())
30567 {
30568 Z_scripterrlog("Script tried to write position '%d' out of bounds on a '%d' size object (%d).", ind, obj->data.size(), objref);
30569 }
30570 else
30571 {
30572 obj->data[ind] = ri->d[rEXP1];
30573 }
30574 }
30575 }
30576 void do_freeclass()
30577 {
30578 dword objref = get_register(sarg1);
30579 if(user_object* obj = checkObject(objref, true))
30580 {
30581 obj->clear();
30582 }
30583 ri->d[rEXP1] = 0;
30584 }
30585
30586 bool zasm_advance()
30587 {
30588 if( key[KEY_INSERT] )
30589 {
30590 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
30591 {
30592 if(key[KEY_LCONTROL] || key[KEY_RCONTROL])
30593 {
30594 FFCore.zasm_break_mode = ZASM_BREAK_SKIP_SCRIPT;
30595 }
30596 else FFCore.zasm_break_mode = ZASM_BREAK_ADVANCE_SCRIPT;
30597 }
30598 else if(key[KEY_ALT] || key[KEY_ALTGR])
30599 {
30600 if(key[KEY_LCONTROL] || key[KEY_RCONTROL])
30601 {
30602 FFCore.zasm_break_mode = ZASM_BREAK_SKIP;
30603 }
30604 else FFCore.zasm_break_mode = ZASM_BREAK_NONE;
30605 }
30606 else if(key[KEY_LCONTROL] || key[KEY_RCONTROL])
30607 {
30608 FFCore.ZASMPrint(false); //Close debugger
30609 FFCore.zasm_break_mode = ZASM_BREAK_NONE;
30610 }
30611 return true;
30612 }
30613 if(!zasm_debugger)
30614 {
30615 FFCore.zasm_break_mode = ZASM_BREAK_NONE;
30616 return true;
30617 }
30618 return false;
30619 }
30620
30621 int32_t get_own_i(ScriptType type)
30622 {
30623 switch(type)
30624 {
30625 case ScriptType::Lwpn:
30626 return ri->lwpn;
30627 case ScriptType::Ewpn:
30628 return ri->ewpn;
30629 case ScriptType::ItemSprite:
30630 return ri->itemref;
30631 case ScriptType::NPC:
30632 return ri->guyref;
30633 case ScriptType::FFC:
30634 return ri->ffcref;
30635 }
30636 return 0;
30637 }
30638
30639 portal* loadportal(savedportal& p);
30640 ///----------------------------------------------------------------------------------------------------//
30641 // Run the script //
30642 ///----------------------------------------------------------------------------------------------------//
30643
30644
30645 10302037 int32_t run_script(ScriptType type, const word script, const int32_t i)
30646 {
30647
2/4
✓ Branch 0 taken 10302037 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10302037 times.
10302037 if(Quit==qRESET || Quit==qEXIT) // In case an earlier script hung
30648 return RUNSCRIPT_ERROR;
30649
30650
4/4
✓ Branch 0 taken 6415543 times.
✓ Branch 1 taken 3886494 times.
✓ Branch 2 taken 5776965 times.
✓ Branch 3 taken 638578 times.
10302037 if(type != ScriptType::Global && !script) return RUNSCRIPT_OK; //Safeguard against running null scripts
30651
30652 9663459 combopos_modified = -1;
30653 9663459 curScriptType=type;
30654 9663459 curScriptNum=script;
30655 9663459 curScriptIndex=i;
30656 //numInstructions=0; //DON'T CLEAR THIS OR IT CAN HARDLOCK! -Em
30657
30658
2/4
✓ Branch 0 taken 9663459 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9663459 times.
9663459 if (!(type >= ScriptType::First && type <= ScriptType::Last))
30659 {
30660 al_trace("Invalid script type: %d\n", type);
30661 return RUNSCRIPT_ERROR;
30662 }
30663
30664 9663459 bool got_initialized = false;
30665
6/8
✓ Branch 0 taken 8919074 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 191687 times.
✓ Branch 4 taken 104554 times.
✓ Branch 5 taken 2517 times.
✓ Branch 6 taken 444085 times.
✓ Branch 7 taken 1542 times.
9663459 switch(type)
30666 {
30667 case ScriptType::FFC:
30668 case ScriptType::Global:
30669 case ScriptType::Player:
30670 case ScriptType::DMap:
30671 case ScriptType::OnMap:
30672 case ScriptType::ActiveSubscreen:
30673 case ScriptType::PassiveSubscreen:
30674 case ScriptType::Screen:
30675 case ScriptType::Combo:
30676 case ScriptType::Item:
30677 {
30678 // TODO: finish refactoring the other script types.
30679 8919074 got_initialized = set_current_script_engine_data(type, script, i);
30680 }
30681 8919074 break;
30682
30683 case ScriptType::NPC:
30684 {
30685 int32_t npc_index = GuyH::getNPCIndex(i);
30686 enemy *w = (enemy*)guys.spr(npc_index);
30687 ri = &(w->scrmem->scriptData);
30688 curscript = guyscripts[w->script];
30689 stack = &(w->scrmem->stack);
30690 ri->guyref = i;
30691
30692 if (!w->initialised)
30693 {
30694 got_initialized = true;
30695 for ( int32_t q = 0; q < 8; q++ )
30696 {
30697 ri->d[q] = w->initD[q];
30698 }
30699 w->initialised = 1;
30700 }
30701 }
30702 break;
30703
30704 case ScriptType::Lwpn:
30705 {
30706 191687 int32_t lwpn_index = LwpnH::getLWeaponIndex(i);
30707 191687 weapon *w = (weapon*)Lwpns.spr(lwpn_index);
30708 191687 ri = &(w->scrmem->scriptData);
30709 191687 curscript = lwpnscripts[w->weaponscript];
30710 191687 stack = &(w->scrmem->stack);
30711 191687 ri->lwpn = i;
30712
30713
2/2
✓ Branch 0 taken 61264 times.
✓ Branch 1 taken 130423 times.
191687 if (!w->initialised)
30714 {
30715 61264 got_initialized = true;
30716
2/2
✓ Branch 0 taken 490112 times.
✓ Branch 1 taken 61264 times.
551376 for ( int32_t q = 0; q < 8; q++ )
30717 {
30718 490112 ri->d[q] = w->weap_initd[q]; //w->initiald[q];
30719 490112 }
30720 61264 w->initialised = 1;
30721 61264 }
30722 }
30723 191687 break;
30724
30725 case ScriptType::Ewpn:
30726 {
30727 104554 int32_t ewpn_index = EwpnH::getEWeaponIndex(i);
30728 104554 weapon *w = (weapon*)Ewpns.spr(ewpn_index);
30729 104554 ri = &(w->scrmem->scriptData);
30730 104554 curscript = ewpnscripts[w->weaponscript];
30731 104554 stack = &(w->scrmem->stack);
30732 104554 ri->ewpn = i;
30733
30734
2/2
✓ Branch 0 taken 1275 times.
✓ Branch 1 taken 103279 times.
104554 if (!w->initialised)
30735 {
30736 1275 got_initialized = true;
30737
2/2
✓ Branch 0 taken 10200 times.
✓ Branch 1 taken 1275 times.
11475 for ( int32_t q = 0; q < 8; q++ )
30738 {
30739 10200 ri->d[q] = w->weap_initd[q];
30740 10200 }
30741 1275 w->initialised = 1;
30742 1275 }
30743 }
30744 104554 break;
30745
30746 case ScriptType::ItemSprite:
30747 {
30748 2517 int32_t the_index = ItemH::getItemIndex(i);
30749 2517 item *w = (item*)items.spr(the_index);
30750 2517 ri = &(w->scrmem->scriptData);
30751 2517 curscript = itemspritescripts[w->script];
30752 2517 stack = &(w->scrmem->stack);
30753 2517 ri->itemref = i;
30754
30755
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 2435 times.
2517 if (!w->initialised)
30756 {
30757 82 got_initialized = true;
30758
2/2
✓ Branch 0 taken 656 times.
✓ Branch 1 taken 82 times.
738 for ( int32_t q = 0; q < 8; q++ )
30759 {
30760 656 ri->d[q] = w->initD[q];
30761 656 }
30762 82 w->initialised = 1;
30763 82 }
30764 }
30765 2517 break;
30766
30767 case ScriptType::Generic:
30768 {
30769 444085 user_genscript& scr = user_scripts[script];
30770 444085 stack = &scr.stack;
30771 444085 ri = &scr.ri;
30772 444085 ri->genericdataref = script;
30773 444085 curscript = genericscripts[script];
30774 444085 scr.waitevent = false;
30775
2/2
✓ Branch 0 taken 443736 times.
✓ Branch 1 taken 349 times.
444085 if(!scr.initialized)
30776 {
30777 349 got_initialized = true;
30778 349 scr.initialized = true;
30779 349 memcpy(ri->d, scr.initd, 8 * sizeof(int32_t));
30780 349 }
30781 }
30782 444085 break;
30783
30784 case ScriptType::GenericFrozen:
30785 {
30786 1542 ri = genericActiveData.back();
30787 1542 ri->genericdataref = script;
30788 1542 curscript = genericscripts[script];
30789 1542 stack = generic_active_stack.back();
30790
2/2
✓ Branch 0 taken 1532 times.
✓ Branch 1 taken 10 times.
1542 if(!gen_active_initialized)
30791 {
30792 10 got_initialized = true;
30793 10 gen_active_initialized = true;
30794 10 memcpy(ri->d, user_scripts[script].initd, 8 * sizeof(int32_t));
30795 10 }
30796 }
30797 1542 break;
30798
30799 default:
30800 {
30801 al_trace("No other scripts are currently supported\n");
30802 return RUNSCRIPT_ERROR;
30803 }
30804 }
30805
30806 // Because qst.cpp likes to write script_data without setting this.
30807 9663459 curscript->meta.script_type = type;
30808
30809 // No need to do anything if the script is not valid.
30810 // An example of this is found in `playground.qst` player scripts, which have scripts with
30811 // a single 0xFFFF command.
30812 // Can't actually do this because we must unset `doscript` via the `scommand == 0xFFFF` handling in run_script_int.
30813 // Otherwise can get freeze, like in ending.cpp
30814 // if (!curscript->valid())
30815 // return RUNSCRIPT_OK;
30816
30817 9663459 script_funcrun = false;
30818
30819
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9663459 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9663459 if (DEBUG_PRINT_ZASM && !seen_scripts.contains(curscript->debug_id))
30820 {
30821 seen_scripts.insert(curscript->debug_id);
30822 ScriptDebugHandle h(ScriptDebugHandle::OutputSplit::ByScript, curscript);
30823 h.print_zasm(curScriptNum, curScriptIndex);
30824 }
30825
30826 9663459 JittedScriptHandle* jitted_script = nullptr;
30827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9663459 times.
9663459 if (jit_is_enabled())
30828 {
30829 9663459 auto it = jitted_scripts.find({curscript, ri});
30830
2/2
✓ Branch 0 taken 11881 times.
✓ Branch 1 taken 9651578 times.
9663459 if (it == jitted_scripts.end())
30831 {
30832 11881 jitted_scripts[{curscript, ri}] = jitted_script = jit_create_script_handle(curscript, ri);
30833 11881 }
30834 else
30835 {
30836 9651578 jitted_script = it->second;
30837 }
30838 9663459 }
30839
30840 9663459 runtime_script_debug_handle = nullptr;
30841
1/2
✓ Branch 0 taken 9663459 times.
✗ Branch 1 not taken.
9663459 if (script_debug_is_runtime_debugging())
30842 {
30843 if (!script_debug_handles.contains(curscript->debug_id))
30844 {
30845 script_debug_handles.emplace(curscript->debug_id, ScriptDebugHandle(ScriptDebugHandle::OutputSplit::ByFrame, curscript));
30846 }
30847 runtime_script_debug_handle = &script_debug_handles.at(curscript->debug_id);
30848 runtime_script_debug_handle->update_file();
30849 runtime_script_debug_handle->print(fmt::format("\n=== running script id: {} name: {} type: {} i: {} script: {}\n", curscript->debug_id, curscript->meta.script_name, ScriptTypeToString(type), i, script).c_str());
30850 }
30851
1/2
✓ Branch 0 taken 9663459 times.
✗ Branch 1 not taken.
9663459 if (script_debug_is_runtime_debugging() == 1)
30852 {
30853 runtime_script_debug_handle->print(script_debug_registers_and_stack_to_string().c_str());
30854 runtime_script_debug_handle->print("\n");
30855 }
30856
30857 int32_t result;
30858
2/2
✓ Branch 0 taken 9662467 times.
✓ Branch 1 taken 992 times.
9663459 if (jitted_script)
30859 {
30860
2/2
✓ Branch 0 taken 9582364 times.
✓ Branch 1 taken 80103 times.
9662467 if (got_initialized)
30861 80103 jit_reinit(jitted_script);
30862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9662467 times.
9662467 if (ri->waitframes)
30863 {
30864 --ri->waitframes;
30865 result = RUNSCRIPT_OK;
30866 }
30867 else
30868 {
30869 9662467 result = jit_run_script(jitted_script);
30870 }
30871 9662467 }
30872 else
30873 {
30874 992 result = run_script_int(false);
30875 }
30876
30877
6/16
✗ Branch 0 not taken.
✓ Branch 1 taken 9663459 times.
✓ Branch 2 taken 9663459 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9663459 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 9663459 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 9663459 times.
✓ Branch 10 taken 9663459 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
19326918 if (replay_is_active() && replay_get_meta_bool("debug_script_state"))
30878 {
30879 std::string str = script_debug_registers_and_stack_to_string();
30880 util::replstr(str, "\n", " ");
30881 replay_step_comment(str);
30882 }
30883
30884 #ifdef _SCRIPT_COUNTER
30885 if (replay_get_frame() > 10000-50)
30886 {
30887 al_trace("\nPrinting ZASM timings:\n\n");
30888
30889 std::vector<std::pair<int, int>> timing_results;
30890 for (int j = 0; j < NUMCOMMANDS; j++)
30891 {
30892 if (script_execount[j])
30893 {
30894 int32_t ms = script_timer[j] / 1000000.0;
30895 timing_results.push_back({j, ms});
30896 }
30897 }
30898 std::sort(timing_results.begin(), timing_results.end(), [](auto &left, auto &right) {
30899 return left.second > right.second;
30900 });
30901 for (auto &it : timing_results)
30902 {
30903 al_trace("Command %s took %d ms complete in %ld executions.\n",
30904 script_debug_command_to_string(it.first).c_str(), it.second, script_execount[it.first]);
30905 }
30906 }
30907 #endif
30908
30909
1/2
✓ Branch 0 taken 9663459 times.
✗ Branch 1 not taken.
9663459 if (runtime_script_debug_handle)
30910 runtime_script_debug_handle->print(fmt::format("result: {}\n", result).c_str());
30911 9663459 return result;
30912 10302037 }
30913
30914 714666597 int32_t run_script_int(bool is_jitted)
30915 {
30916 714666597 ScriptType type = curScriptType;
30917 714666597 word script = curScriptNum;
30918 714666597 int32_t i = curScriptIndex;
30919
30920 714666597 int commands_run = 0;
30921
2/2
✓ Branch 0 taken 714665605 times.
✓ Branch 1 taken 992 times.
714666597 if (is_jitted) goto j_command;
30922
30923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 992 times.
992 if(ri->waitframes)
30924 {
30925 --ri->waitframes;
30926 return RUNSCRIPT_OK;
30927 }
30928 992 zs_vargs.clear();
30929
30930 #ifdef _FFDISSASSEMBLY
30931
30932 if(curscript->zasm[ri->pc].command != 0xFFFF)
30933 {
30934 #ifdef _FFONESCRIPTDISSASSEMBLY
30935 zc_trace_clear();
30936 #endif
30937
30938 switch(type)
30939 {
30940 case ScriptType::FFC:
30941 al_trace("\nStart of FFC script %i processing on FFC %i:\n", script, i);
30942 break;
30943
30944 case ScriptType::Item:
30945 al_trace("\nStart of item script %i processing:\n", script);
30946 break;
30947
30948 case ScriptType::Global:
30949 al_trace("\nStart of global script %I processing:\n", script);
30950 break;
30951 }
30952 }
30953
30954 #endif
30955
30956
2/4
✓ Branch 0 taken 992 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 992 times.
1984 if( FFCore.zasm_break_mode == ZASM_BREAK_ADVANCE_SCRIPT || FFCore.zasm_break_mode == ZASM_BREAK_SKIP_SCRIPT )
30957 {
30958 if( zasm_debugger )
30959 {
30960 //Halt on new script if set to advance to next script
30961 FFCore.zasm_break_mode = ZASM_BREAK_HALT;
30962 FFCore.TraceScriptIDs(true);
30963 coloured_console.safeprint((CConsoleLoggerEx::COLOR_RED |
30964 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),"Breaking for script start\n");
30965 }
30966 else FFCore.zasm_break_mode = ZASM_BREAK_NONE;
30967 }
30968
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 992 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
992 else if( zasm_debugger && !(SKIPZASMPRINT()))
30969 {
30970 //Print new script metadata when starting script
30971 FFCore.TraceScriptIDs(true);
30972 coloured_console.safeprint((CConsoleLoggerEx::COLOR_RED |
30973 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),"Start of script\n");
30974 }
30975
30976 j_command:
30977 714666597 bool is_debugging = script_debug_is_runtime_debugging() == 2;
30978 714666597 bool increment = true;
30979 714666597 word scommand = curscript->zasm[ri->pc].command;
30980 714666597 bool hit_invalid_zasm = false;
30981 714666597 bool no_dealloc = false;
30982
2/2
✓ Branch 0 taken 1005 times.
✓ Branch 1 taken 717755190 times.
717756195 while(scommand != 0xFFFF)
30983 {
30984 #ifdef _SCRIPT_COUNTER
30985 std::chrono::steady_clock::time_point start_time, end_time;
30986 start_time = std::chrono::steady_clock::now();
30987 #endif
30988
30989 717755190 scommand = curscript->zasm[ri->pc].command;
30990 717755190 sarg1 = curscript->zasm[ri->pc].arg1;
30991 717755190 sarg2 = curscript->zasm[ri->pc].arg2;
30992 717755190 sargstr = curscript->zasm[ri->pc].strptr;
30993 717755190 sargvec = curscript->zasm[ri->pc].vecptr;
30994 //zprint2("Executing zasm: %d,%d,%d,%d,%d\n",scommand,sarg1,sarg2,get_register(sarg1),get_register(sarg2));
30995
30996
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 717755190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
717755190 if (is_debugging && (!is_jitted || commands_run > 0))
30997 {
30998 runtime_script_debug_handle->pre_command();
30999 }
31000
31001 717755190 bool waiting = true;
31002
4/6
✓ Branch 0 taken 708162214 times.
✓ Branch 1 taken 1864084 times.
✓ Branch 2 taken 177522 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7551370 times.
✗ Branch 5 not taken.
717755190 switch(scommand) //Handle waitframe-type commands first
31003 {
31004 case WAITDRAW:
31005 {
31006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1864084 times.
1864084 if(script_funcrun)
31007 scommand = NOP;
31008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1864084 times.
1864084 else switch(type)
31009 {
31010 case ScriptType::Generic:
31011 case ScriptType::GenericFrozen: //ignore waitdraws
31012 Z_scripterrlog("'Waitdraw()' is invalid in generic scripts, will be ignored\n");
31013 scommand = NOP;
31014 break;
31015 }
31016 1864084 break;
31017 }
31018 case WAITTO:
31019 {
31020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177522 times.
177522 if(script_funcrun)
31021 scommand = NOP;
31022
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 177522 times.
177522 else switch(type)
31023 {
31024 case ScriptType::GenericFrozen:
31025 //ignore, no warn/error
31026 scommand = NOP;
31027 break;
31028 case ScriptType::Generic:
31029 {
31030 177522 user_genscript& scr = user_scripts[script];
31031 177522 int32_t target = get_register(sarg1)/10000L;
31032 177522 bool atleast = get_register(sarg2)!=0;
31033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177522 times.
177522 if(unsigned(target) > SCR_TIMING_END_FRAME)
31034 {
31035 Z_scripterrlog("Invalid value '%d' provided to 'WaitTo()'\n", target);
31036 scommand = NOP;
31037 break;
31038 }
31039
1/4
✓ Branch 0 taken 177522 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
177522 if(genscript_timing == target ||
31040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177522 times.
177522 (atleast && genscript_timing < target))
31041 {
31042 //Already that time, skip the command
31043 scommand = NOP;
31044 break;
31045 }
31046 177522 scr.waituntil = scr_timing(target);
31047 177522 scr.wait_atleast = atleast;
31048 177522 break;
31049 }
31050 default:
31051 Z_scripterrlog("'WaitTo()' is only valid in 'generic' scripts!\n");
31052 scommand = NOP;
31053 break;
31054 }
31055 177522 break;
31056 }
31057 case WAITEVENT:
31058 {
31059 if(script_funcrun)
31060 scommand = NOP;
31061 else switch(type)
31062 {
31063 case ScriptType::GenericFrozen:
31064 scommand = WAITFRAME;
31065 ri->d[0] = GENSCR_EVENT_NIL*10000; //no event
31066 break;
31067 case ScriptType::Generic:
31068 {
31069 user_genscript& scr = user_scripts[script];
31070 scr.waitevent = true;
31071 break;
31072 }
31073 default:
31074 Z_scripterrlog("'WaitEvent()' is only valid in 'generic' scripts!\n");
31075 scommand = NOP;
31076 break;
31077 }
31078 break;
31079 }
31080 case WAITFRAME:
31081 {
31082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7551370 times.
7551370 if(script_funcrun)
31083 scommand = NOP;
31084
2/2
✓ Branch 0 taken 7284807 times.
✓ Branch 1 taken 266563 times.
7551370 else switch(type)
31085 {
31086 case ScriptType::Generic:
31087 266563 user_scripts[script].waituntil = SCR_TIMING_START_FRAME;
31088 266563 user_scripts[script].wait_atleast = false;
31089 266563 break;
31090 }
31091 7551370 break;
31092 }
31093 case WAITFRAMESR:
31094 {
31095 auto count = get_register(sarg1);
31096 if(script_funcrun || count <= 0)
31097 {
31098 scommand = NOP;
31099 break;
31100 }
31101 auto frames = count/10000;
31102 if(count%10000) ++frames; //round up decimals
31103 ri->waitframes = frames-1; //this frame doesn't count
31104 switch(type)
31105 {
31106 case ScriptType::Generic:
31107 user_scripts[script].waituntil = SCR_TIMING_START_FRAME;
31108 user_scripts[script].wait_atleast = false;
31109 break;
31110 }
31111 break;
31112 }
31113 708162214 default: waiting = false;
31114 708162214 }
31115
3/4
✓ Branch 0 taken 9592976 times.
✓ Branch 1 taken 708162214 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9592976 times.
717755190 if(waiting && scommand != NOP)
31116 9592976 break;
31117
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 708162214 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
708162214 if(waiting && is_jitted)
31118 break;
31119
31120 708162214 numInstructions++;
31121
2/2
✓ Branch 0 taken 707454080 times.
✓ Branch 1 taken 708134 times.
708162214 if(numInstructions==hangcount) // No need to check frequently
31122 {
31123 708134 numInstructions=0;
31124 708134 poll_keyboard();
31125 708134 checkQuitKeys();
31126
1/2
✓ Branch 0 taken 708134 times.
✗ Branch 1 not taken.
708134 if(Quit)
31127 scommand=0xFFFF;
31128 708134 }
31129
31130 //Handle manual breaking
31131
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 708162214 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
708162214 if( zasm_debugger && zc_readrawkey(KEY_INSERT, true))
31132 FFCore.zasm_break_mode = ZASM_BREAK_HALT;
31133 //Break
31134
1/2
✓ Branch 0 taken 708162214 times.
✗ Branch 1 not taken.
708162214 while( FFCore.zasm_break_mode == ZASM_BREAK_HALT )
31135 {
31136 poll_keyboard();
31137 if(zasm_advance()) break;
31138 checkQuitKeys();
31139 if(Quit)
31140 {
31141 scommand=0xFFFF;
31142 break;
31143 }
31144 }
31145
31146
1/2
✓ Branch 0 taken 708162214 times.
✗ Branch 1 not taken.
708162214 if ( zasm_debugger ) FFCore.ZASMPrintCommand(scommand);
31147
145/907
✓ Branch 0 taken 5580 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 57032 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 589793 times.
✓ Branch 7 taken 37361745 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 69468 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 62707768 times.
✓ Branch 33 taken 31824855 times.
✓ Branch 34 taken 38172927 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 22050889 times.
✓ Branch 37 taken 2928911 times.
✓ Branch 38 taken 241209 times.
✓ Branch 39 taken 334 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✓ Branch 57 taken 58814 times.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✓ Branch 69 taken 327 times.
✗ Branch 70 not taken.
✓ Branch 71 taken 7021113 times.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✓ Branch 75 taken 6996587 times.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✓ Branch 78 taken 294114413 times.
✗ Branch 79 not taken.
✗ Branch 80 not taken.
✗ Branch 81 not taken.
✗ Branch 82 not taken.
✗ Branch 83 not taken.
✗ Branch 84 not taken.
✗ Branch 85 not taken.
✓ Branch 86 taken 227724 times.
✓ Branch 87 taken 80 times.
✗ Branch 88 not taken.
✗ Branch 89 not taken.
✗ Branch 90 not taken.
✗ Branch 91 not taken.
✗ Branch 92 not taken.
✗ Branch 93 not taken.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✗ Branch 96 not taken.
✗ Branch 97 not taken.
✓ Branch 98 taken 930 times.
✗ Branch 99 not taken.
✗ Branch 100 not taken.
✓ Branch 101 taken 252 times.
✗ Branch 102 not taken.
✗ Branch 103 not taken.
✓ Branch 104 taken 6163735 times.
✗ Branch 105 not taken.
✓ Branch 106 taken 3204584 times.
✗ Branch 107 not taken.
✓ Branch 108 taken 76 times.
✓ Branch 109 taken 1263 times.
✓ Branch 110 taken 59701 times.
✓ Branch 111 taken 2629 times.
✓ Branch 112 taken 14918 times.
✗ Branch 113 not taken.
✓ Branch 114 taken 863764 times.
✓ Branch 115 taken 1259 times.
✓ Branch 116 taken 13724 times.
✓ Branch 117 taken 37547 times.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✓ Branch 120 taken 1 times.
✗ Branch 121 not taken.
✓ Branch 122 taken 1072 times.
✗ Branch 123 not taken.
✗ Branch 124 not taken.
✗ Branch 125 not taken.
✗ Branch 126 not taken.
✗ Branch 127 not taken.
✗ Branch 128 not taken.
✗ Branch 129 not taken.
✗ Branch 130 not taken.
✗ Branch 131 not taken.
✗ Branch 132 not taken.
✓ Branch 133 taken 4761 times.
✗ Branch 134 not taken.
✗ Branch 135 not taken.
✗ Branch 136 not taken.
✗ Branch 137 not taken.
✗ Branch 138 not taken.
✗ Branch 139 not taken.
✗ Branch 140 not taken.
✗ Branch 141 not taken.
✗ Branch 142 not taken.
✗ Branch 143 not taken.
✗ Branch 144 not taken.
✓ Branch 145 taken 1 times.
✗ Branch 146 not taken.
✗ Branch 147 not taken.
✗ Branch 148 not taken.
✓ Branch 149 taken 602 times.
✓ Branch 150 taken 1275 times.
✗ Branch 151 not taken.
✓ Branch 152 taken 68 times.
✗ Branch 153 not taken.
✓ Branch 154 taken 105 times.
✗ Branch 155 not taken.
✓ Branch 156 taken 31 times.
✗ Branch 157 not taken.
✗ Branch 158 not taken.
✗ Branch 159 not taken.
✗ Branch 160 not taken.
✗ Branch 161 not taken.
✗ Branch 162 not taken.
✗ Branch 163 not taken.
✗ Branch 164 not taken.
✗ Branch 165 not taken.
✗ Branch 166 not taken.
✗ Branch 167 not taken.
✓ Branch 168 taken 25969 times.
✓ Branch 169 taken 71 times.
✗ Branch 170 not taken.
✓ Branch 171 taken 25971 times.
✓ Branch 172 taken 31488 times.
✓ Branch 173 taken 2703958 times.
✗ Branch 174 not taken.
✗ Branch 175 not taken.
✗ Branch 176 not taken.
✗ Branch 177 not taken.
✗ Branch 178 not taken.
✗ Branch 179 not taken.
✗ Branch 180 not taken.
✗ Branch 181 not taken.
✓ Branch 182 taken 2539388 times.
✓ Branch 183 taken 77 times.
✗ Branch 184 not taken.
✗ Branch 185 not taken.
✗ Branch 186 not taken.
✗ Branch 187 not taken.
✗ Branch 188 not taken.
✗ Branch 189 not taken.
✗ Branch 190 not taken.
✓ Branch 191 taken 27 times.
✓ Branch 192 taken 20 times.
✗ Branch 193 not taken.
✗ Branch 194 not taken.
✓ Branch 195 taken 5580675 times.
✓ Branch 196 taken 153457 times.
✓ Branch 197 taken 191294 times.
✓ Branch 198 taken 3 times.
✗ Branch 199 not taken.
✗ Branch 200 not taken.
✗ Branch 201 not taken.
✗ Branch 202 not taken.
✗ Branch 203 not taken.
✗ Branch 204 not taken.
✓ Branch 205 taken 1427960 times.
✓ Branch 206 taken 62330372 times.
✓ Branch 207 taken 510425 times.
✓ Branch 208 taken 20228358 times.
✓ Branch 209 taken 375777 times.
✓ Branch 210 taken 34306 times.
✗ Branch 211 not taken.
✓ Branch 212 taken 17 times.
✗ Branch 213 not taken.
✗ Branch 214 not taken.
✗ Branch 215 not taken.
✗ Branch 216 not taken.
✓ Branch 217 taken 22 times.
✗ Branch 218 not taken.
✓ Branch 219 taken 34296 times.
✗ Branch 220 not taken.
✓ Branch 221 taken 3603 times.
✗ Branch 222 not taken.
✗ Branch 223 not taken.
✗ Branch 224 not taken.
✗ Branch 225 not taken.
✗ Branch 226 not taken.
✗ Branch 227 not taken.
✗ Branch 228 not taken.
✗ Branch 229 not taken.
✗ Branch 230 not taken.
✗ Branch 231 not taken.
✗ Branch 232 not taken.
✗ Branch 233 not taken.
✗ Branch 234 not taken.
✓ Branch 235 taken 2 times.
✓ Branch 236 taken 1 times.
✓ Branch 237 taken 384 times.
✓ Branch 238 taken 287 times.
✓ Branch 239 taken 11645 times.
✓ Branch 240 taken 3322 times.
✗ Branch 241 not taken.
✗ Branch 242 not taken.
✗ Branch 243 not taken.
✓ Branch 244 taken 79 times.
✗ Branch 245 not taken.
✓ Branch 246 taken 126 times.
✗ Branch 247 not taken.
✗ Branch 248 not taken.
✗ Branch 249 not taken.
✓ Branch 250 taken 5268 times.
✗ Branch 251 not taken.
✗ Branch 252 not taken.
✓ Branch 253 taken 170815 times.
✗ Branch 254 not taken.
✗ Branch 255 not taken.
✗ Branch 256 not taken.
✗ Branch 257 not taken.
✗ Branch 258 not taken.
✗ Branch 259 not taken.
✗ Branch 260 not taken.
✓ Branch 261 taken 63813 times.
✗ Branch 262 not taken.
✓ Branch 263 taken 79 times.
✓ Branch 264 taken 100 times.
✓ Branch 265 taken 5 times.
✓ Branch 266 taken 3750 times.
✗ Branch 267 not taken.
✗ Branch 268 not taken.
✗ Branch 269 not taken.
✗ Branch 270 not taken.
✗ Branch 271 not taken.
✗ Branch 272 not taken.
✗ Branch 273 not taken.
✗ Branch 274 not taken.
✗ Branch 275 not taken.
✗ Branch 276 not taken.
✗ Branch 277 not taken.
✗ Branch 278 not taken.
✗ Branch 279 not taken.
✗ Branch 280 not taken.
✓ Branch 281 taken 173 times.
✗ Branch 282 not taken.
✓ Branch 283 taken 2691 times.
✗ Branch 284 not taken.
✗ Branch 285 not taken.
✓ Branch 286 taken 10 times.
✗ Branch 287 not taken.
✓ Branch 288 taken 3666 times.
✗ Branch 289 not taken.
✗ Branch 290 not taken.
✓ Branch 291 taken 701 times.
✗ Branch 292 not taken.
✗ Branch 293 not taken.
✗ Branch 294 not taken.
✗ Branch 295 not taken.
✓ Branch 296 taken 1201098 times.
✗ Branch 297 not taken.
✓ Branch 298 taken 2753647 times.
✗ Branch 299 not taken.
✓ Branch 300 taken 136832 times.
✗ Branch 301 not taken.
✓ Branch 302 taken 1816935 times.
✗ Branch 303 not taken.
✗ Branch 304 not taken.
✗ Branch 305 not taken.
✗ Branch 306 not taken.
✗ Branch 307 not taken.
✗ Branch 308 not taken.
✓ Branch 309 taken 25412 times.
✗ Branch 310 not taken.
✗ Branch 311 not taken.
✗ Branch 312 not taken.
✓ Branch 313 taken 403560 times.
✓ Branch 314 taken 177544 times.
✓ Branch 315 taken 16 times.
✗ Branch 316 not taken.
✗ Branch 317 not taken.
✗ Branch 318 not taken.
✗ Branch 319 not taken.
✗ Branch 320 not taken.
✓ Branch 321 taken 800680 times.
✗ Branch 322 not taken.
✗ Branch 323 not taken.
✗ Branch 324 not taken.
✗ Branch 325 not taken.
✗ Branch 326 not taken.
✗ Branch 327 not taken.
✗ Branch 328 not taken.
✗ Branch 329 not taken.
✗ Branch 330 not taken.
✗ Branch 331 not taken.
✗ Branch 332 not taken.
✗ Branch 333 not taken.
✗ Branch 334 not taken.
✗ Branch 335 not taken.
✗ Branch 336 not taken.
✗ Branch 337 not taken.
✗ Branch 338 not taken.
✗ Branch 339 not taken.
✗ Branch 340 not taken.
✗ Branch 341 not taken.
✗ Branch 342 not taken.
✗ Branch 343 not taken.
✗ Branch 344 not taken.
✗ Branch 345 not taken.
✗ Branch 346 not taken.
✗ Branch 347 not taken.
✗ Branch 348 not taken.
✗ Branch 349 not taken.
✗ Branch 350 not taken.
✗ Branch 351 not taken.
✗ Branch 352 not taken.
✗ Branch 353 not taken.
✓ Branch 354 taken 22 times.
✗ Branch 355 not taken.
✗ Branch 356 not taken.
✗ Branch 357 not taken.
✗ Branch 358 not taken.
✗ Branch 359 not taken.
✗ Branch 360 not taken.
✗ Branch 361 not taken.
✗ Branch 362 not taken.
✗ Branch 363 not taken.
✗ Branch 364 not taken.
✗ Branch 365 not taken.
✗ Branch 366 not taken.
✗ Branch 367 not taken.
✗ Branch 368 not taken.
✗ Branch 369 not taken.
✗ Branch 370 not taken.
✗ Branch 371 not taken.
✗ Branch 372 not taken.
✗ Branch 373 not taken.
✗ Branch 374 not taken.
✗ Branch 375 not taken.
✗ Branch 376 not taken.
✗ Branch 377 not taken.
✗ Branch 378 not taken.
✗ Branch 379 not taken.
✗ Branch 380 not taken.
✗ Branch 381 not taken.
✗ Branch 382 not taken.
✓ Branch 383 taken 12 times.
✓ Branch 384 taken 598 times.
✗ Branch 385 not taken.
✓ Branch 386 taken 15641785 times.
✗ Branch 387 not taken.
✓ Branch 388 taken 77278 times.
✗ Branch 389 not taken.
✓ Branch 390 taken 131917 times.
✗ Branch 391 not taken.
✓ Branch 392 taken 21343 times.
✗ Branch 393 not taken.
✓ Branch 394 taken 2363 times.
✗ Branch 395 not taken.
✓ Branch 396 taken 565 times.
✓ Branch 397 taken 27033 times.
✓ Branch 398 taken 10 times.
✓ Branch 399 taken 43 times.
✓ Branch 400 taken 6259830 times.
✓ Branch 401 taken 593592 times.
✓ Branch 402 taken 122622 times.
✗ Branch 403 not taken.
✗ Branch 404 not taken.
✗ Branch 405 not taken.
✗ Branch 406 not taken.
✓ Branch 407 taken 15079 times.
✗ Branch 408 not taken.
✓ Branch 409 taken 132144 times.
✗ Branch 410 not taken.
✗ Branch 411 not taken.
✗ Branch 412 not taken.
✓ Branch 413 taken 16274661 times.
✗ Branch 414 not taken.
✗ Branch 415 not taken.
✗ Branch 416 not taken.
✓ Branch 417 taken 249 times.
✓ Branch 418 taken 5 times.
✓ Branch 419 taken 354940 times.
✗ Branch 420 not taken.
✗ Branch 421 not taken.
✓ Branch 422 taken 354943 times.
✓ Branch 423 taken 3 times.
✓ Branch 424 taken 3 times.
✓ Branch 425 taken 12696160 times.
✓ Branch 426 taken 16038753 times.
✓ Branch 427 taken 60 times.
✗ Branch 428 not taken.
✗ Branch 429 not taken.
✗ Branch 430 not taken.
✗ Branch 431 not taken.
✗ Branch 432 not taken.
✗ Branch 433 not taken.
✗ Branch 434 not taken.
✗ Branch 435 not taken.
✗ Branch 436 not taken.
✗ Branch 437 not taken.
✗ Branch 438 not taken.
✗ Branch 439 not taken.
✗ Branch 440 not taken.
✗ Branch 441 not taken.
✗ Branch 442 not taken.
✗ Branch 443 not taken.
✗ Branch 444 not taken.
✓ Branch 445 taken 2564 times.
✗ Branch 446 not taken.
✗ Branch 447 not taken.
✗ Branch 448 not taken.
✗ Branch 449 not taken.
✓ Branch 450 taken 26528 times.
✓ Branch 451 taken 3512 times.
✓ Branch 452 taken 146 times.
✗ Branch 453 not taken.
✗ Branch 454 not taken.
✗ Branch 455 not taken.
✗ Branch 456 not taken.
✗ Branch 457 not taken.
✗ Branch 458 not taken.
✗ Branch 459 not taken.
✗ Branch 460 not taken.
✗ Branch 461 not taken.
✗ Branch 462 not taken.
✗ Branch 463 not taken.
✓ Branch 464 taken 16962076 times.
✗ Branch 465 not taken.
✗ Branch 466 not taken.
✗ Branch 467 not taken.
✗ Branch 468 not taken.
✗ Branch 469 not taken.
✗ Branch 470 not taken.
✗ Branch 471 not taken.
✗ Branch 472 not taken.
✗ Branch 473 not taken.
✗ Branch 474 not taken.
✗ Branch 475 not taken.
✗ Branch 476 not taken.
✗ Branch 477 not taken.
✗ Branch 478 not taken.
✗ Branch 479 not taken.
✗ Branch 480 not taken.
✗ Branch 481 not taken.
✗ Branch 482 not taken.
✗ Branch 483 not taken.
✗ Branch 484 not taken.
✓ Branch 485 taken 3535588 times.
✓ Branch 486 taken 1 times.
✗ Branch 487 not taken.
✗ Branch 488 not taken.
✗ Branch 489 not taken.
✗ Branch 490 not taken.
✗ Branch 491 not taken.
✓ Branch 492 taken 11 times.
✗ Branch 493 not taken.
✗ Branch 494 not taken.
✗ Branch 495 not taken.
✗ Branch 496 not taken.
✗ Branch 497 not taken.
✗ Branch 498 not taken.
✗ Branch 499 not taken.
✗ Branch 500 not taken.
✗ Branch 501 not taken.
✗ Branch 502 not taken.
✗ Branch 503 not taken.
✗ Branch 504 not taken.
✗ Branch 505 not taken.
✗ Branch 506 not taken.
✗ Branch 507 not taken.
✗ Branch 508 not taken.
✗ Branch 509 not taken.
✗ Branch 510 not taken.
✗ Branch 511 not taken.
✗ Branch 512 not taken.
✗ Branch 513 not taken.
✗ Branch 514 not taken.
✗ Branch 515 not taken.
✗ Branch 516 not taken.
✗ Branch 517 not taken.
✗ Branch 518 not taken.
✓ Branch 519 taken 16 times.
✗ Branch 520 not taken.
✗ Branch 521 not taken.
✗ Branch 522 not taken.
✗ Branch 523 not taken.
✗ Branch 524 not taken.
✗ Branch 525 not taken.
✗ Branch 526 not taken.
✗ Branch 527 not taken.
✗ Branch 528 not taken.
✗ Branch 529 not taken.
✗ Branch 530 not taken.
✗ Branch 531 not taken.
✗ Branch 532 not taken.
✗ Branch 533 not taken.
✗ Branch 534 not taken.
✗ Branch 535 not taken.
✗ Branch 536 not taken.
✗ Branch 537 not taken.
✗ Branch 538 not taken.
✗ Branch 539 not taken.
✗ Branch 540 not taken.
✗ Branch 541 not taken.
✗ Branch 542 not taken.
✗ Branch 543 not taken.
✗ Branch 544 not taken.
✗ Branch 545 not taken.
✓ Branch 546 taken 15 times.
✗ Branch 547 not taken.
✗ Branch 548 not taken.
✗ Branch 549 not taken.
✗ Branch 550 not taken.
✗ Branch 551 not taken.
✗ Branch 552 not taken.
✗ Branch 553 not taken.
✗ Branch 554 not taken.
✗ Branch 555 not taken.
✗ Branch 556 not taken.
✗ Branch 557 not taken.
✗ Branch 558 not taken.
✗ Branch 559 not taken.
✗ Branch 560 not taken.
✗ Branch 561 not taken.
✗ Branch 562 not taken.
✗ Branch 563 not taken.
✗ Branch 564 not taken.
✗ Branch 565 not taken.
✗ Branch 566 not taken.
✗ Branch 567 not taken.
✗ Branch 568 not taken.
✗ Branch 569 not taken.
✗ Branch 570 not taken.
✗ Branch 571 not taken.
✗ Branch 572 not taken.
✗ Branch 573 not taken.
✗ Branch 574 not taken.
✗ Branch 575 not taken.
✗ Branch 576 not taken.
✗ Branch 577 not taken.
✗ Branch 578 not taken.
✗ Branch 579 not taken.
✗ Branch 580 not taken.
✗ Branch 581 not taken.
✗ Branch 582 not taken.
✗ Branch 583 not taken.
✗ Branch 584 not taken.
✗ Branch 585 not taken.
✗ Branch 586 not taken.
✗ Branch 587 not taken.
✗ Branch 588 not taken.
✗ Branch 589 not taken.
✗ Branch 590 not taken.
✗ Branch 591 not taken.
✗ Branch 592 not taken.
✗ Branch 593 not taken.
✗ Branch 594 not taken.
✗ Branch 595 not taken.
✗ Branch 596 not taken.
✗ Branch 597 not taken.
✗ Branch 598 not taken.
✗ Branch 599 not taken.
✗ Branch 600 not taken.
✗ Branch 601 not taken.
✗ Branch 602 not taken.
✗ Branch 603 not taken.
✗ Branch 604 not taken.
✗ Branch 605 not taken.
✗ Branch 606 not taken.
✗ Branch 607 not taken.
✗ Branch 608 not taken.
✗ Branch 609 not taken.
✗ Branch 610 not taken.
✗ Branch 611 not taken.
✗ Branch 612 not taken.
✗ Branch 613 not taken.
✗ Branch 614 not taken.
✗ Branch 615 not taken.
✗ Branch 616 not taken.
✗ Branch 617 not taken.
✗ Branch 618 not taken.
✗ Branch 619 not taken.
✗ Branch 620 not taken.
✗ Branch 621 not taken.
✗ Branch 622 not taken.
✗ Branch 623 not taken.
✗ Branch 624 not taken.
✗ Branch 625 not taken.
✗ Branch 626 not taken.
✗ Branch 627 not taken.
✗ Branch 628 not taken.
✗ Branch 629 not taken.
✗ Branch 630 not taken.
✗ Branch 631 not taken.
✗ Branch 632 not taken.
✗ Branch 633 not taken.
✗ Branch 634 not taken.
✗ Branch 635 not taken.
✗ Branch 636 not taken.
✗ Branch 637 not taken.
✗ Branch 638 not taken.
✗ Branch 639 not taken.
✗ Branch 640 not taken.
✗ Branch 641 not taken.
✗ Branch 642 not taken.
✗ Branch 643 not taken.
✗ Branch 644 not taken.
✗ Branch 645 not taken.
✗ Branch 646 not taken.
✗ Branch 647 not taken.
✗ Branch 648 not taken.
✗ Branch 649 not taken.
✗ Branch 650 not taken.
✗ Branch 651 not taken.
✗ Branch 652 not taken.
✗ Branch 653 not taken.
✗ Branch 654 not taken.
✗ Branch 655 not taken.
✗ Branch 656 not taken.
✗ Branch 657 not taken.
✗ Branch 658 not taken.
✗ Branch 659 not taken.
✗ Branch 660 not taken.
✗ Branch 661 not taken.
✗ Branch 662 not taken.
✗ Branch 663 not taken.
✗ Branch 664 not taken.
✗ Branch 665 not taken.
✗ Branch 666 not taken.
✗ Branch 667 not taken.
✗ Branch 668 not taken.
✗ Branch 669 not taken.
✗ Branch 670 not taken.
✗ Branch 671 not taken.
✗ Branch 672 not taken.
✗ Branch 673 not taken.
✗ Branch 674 not taken.
✗ Branch 675 not taken.
✗ Branch 676 not taken.
✗ Branch 677 not taken.
✗ Branch 678 not taken.
✗ Branch 679 not taken.
✗ Branch 680 not taken.
✗ Branch 681 not taken.
✗ Branch 682 not taken.
✗ Branch 683 not taken.
✗ Branch 684 not taken.
✗ Branch 685 not taken.
✗ Branch 686 not taken.
✗ Branch 687 not taken.
✗ Branch 688 not taken.
✗ Branch 689 not taken.
✗ Branch 690 not taken.
✗ Branch 691 not taken.
✗ Branch 692 not taken.
✗ Branch 693 not taken.
✗ Branch 694 not taken.
✗ Branch 695 not taken.
✗ Branch 696 not taken.
✗ Branch 697 not taken.
✗ Branch 698 not taken.
✗ Branch 699 not taken.
✗ Branch 700 not taken.
✗ Branch 701 not taken.
✗ Branch 702 not taken.
✗ Branch 703 not taken.
✗ Branch 704 not taken.
✗ Branch 705 not taken.
✗ Branch 706 not taken.
✗ Branch 707 not taken.
✗ Branch 708 not taken.
✗ Branch 709 not taken.
✗ Branch 710 not taken.
✗ Branch 711 not taken.
✗ Branch 712 not taken.
✗ Branch 713 not taken.
✗ Branch 714 not taken.
✗ Branch 715 not taken.
✗ Branch 716 not taken.
✗ Branch 717 not taken.
✗ Branch 718 not taken.
✗ Branch 719 not taken.
✗ Branch 720 not taken.
✗ Branch 721 not taken.
✗ Branch 722 not taken.
✗ Branch 723 not taken.
✗ Branch 724 not taken.
✗ Branch 725 not taken.
✗ Branch 726 not taken.
✗ Branch 727 not taken.
✗ Branch 728 not taken.
✗ Branch 729 not taken.
✗ Branch 730 not taken.
✗ Branch 731 not taken.
✗ Branch 732 not taken.
✗ Branch 733 not taken.
✗ Branch 734 not taken.
✗ Branch 735 not taken.
✗ Branch 736 not taken.
✗ Branch 737 not taken.
✗ Branch 738 not taken.
✗ Branch 739 not taken.
✗ Branch 740 not taken.
✗ Branch 741 not taken.
✗ Branch 742 not taken.
✗ Branch 743 not taken.
✗ Branch 744 not taken.
✗ Branch 745 not taken.
✗ Branch 746 not taken.
✗ Branch 747 not taken.
✗ Branch 748 not taken.
✗ Branch 749 not taken.
✗ Branch 750 not taken.
✗ Branch 751 not taken.
✗ Branch 752 not taken.
✗ Branch 753 not taken.
✗ Branch 754 not taken.
✗ Branch 755 not taken.
✗ Branch 756 not taken.
✗ Branch 757 not taken.
✗ Branch 758 not taken.
✗ Branch 759 not taken.
✗ Branch 760 not taken.
✗ Branch 761 not taken.
✗ Branch 762 not taken.
✗ Branch 763 not taken.
✗ Branch 764 not taken.
✗ Branch 765 not taken.
✗ Branch 766 not taken.
✗ Branch 767 not taken.
✗ Branch 768 not taken.
✗ Branch 769 not taken.
✗ Branch 770 not taken.
✗ Branch 771 not taken.
✗ Branch 772 not taken.
✗ Branch 773 not taken.
✗ Branch 774 not taken.
✗ Branch 775 not taken.
✗ Branch 776 not taken.
✗ Branch 777 not taken.
✗ Branch 778 not taken.
✗ Branch 779 not taken.
✗ Branch 780 not taken.
✗ Branch 781 not taken.
✗ Branch 782 not taken.
✗ Branch 783 not taken.
✗ Branch 784 not taken.
✗ Branch 785 not taken.
✗ Branch 786 not taken.
✗ Branch 787 not taken.
✗ Branch 788 not taken.
✗ Branch 789 not taken.
✗ Branch 790 not taken.
✗ Branch 791 not taken.
✗ Branch 792 not taken.
✗ Branch 793 not taken.
✗ Branch 794 not taken.
✗ Branch 795 not taken.
✗ Branch 796 not taken.
✗ Branch 797 not taken.
✗ Branch 798 not taken.
✗ Branch 799 not taken.
✗ Branch 800 not taken.
✗ Branch 801 not taken.
✗ Branch 802 not taken.
✗ Branch 803 not taken.
✗ Branch 804 not taken.
✗ Branch 805 not taken.
✗ Branch 806 not taken.
✗ Branch 807 not taken.
✓ Branch 808 taken 2 times.
✗ Branch 809 not taken.
✓ Branch 810 taken 8 times.
✗ Branch 811 not taken.
✗ Branch 812 not taken.
✗ Branch 813 not taken.
✗ Branch 814 not taken.
✗ Branch 815 not taken.
✗ Branch 816 not taken.
✗ Branch 817 not taken.
✗ Branch 818 not taken.
✗ Branch 819 not taken.
✗ Branch 820 not taken.
✗ Branch 821 not taken.
✗ Branch 822 not taken.
✗ Branch 823 not taken.
✗ Branch 824 not taken.
✗ Branch 825 not taken.
✗ Branch 826 not taken.
✗ Branch 827 not taken.
✗ Branch 828 not taken.
✗ Branch 829 not taken.
✗ Branch 830 not taken.
✗ Branch 831 not taken.
✗ Branch 832 not taken.
✗ Branch 833 not taken.
✗ Branch 834 not taken.
✗ Branch 835 not taken.
✗ Branch 836 not taken.
✗ Branch 837 not taken.
✗ Branch 838 not taken.
✗ Branch 839 not taken.
✗ Branch 840 not taken.
✗ Branch 841 not taken.
✗ Branch 842 not taken.
✗ Branch 843 not taken.
✗ Branch 844 not taken.
✗ Branch 845 not taken.
✗ Branch 846 not taken.
✗ Branch 847 not taken.
✗ Branch 848 not taken.
✗ Branch 849 not taken.
✗ Branch 850 not taken.
✗ Branch 851 not taken.
✗ Branch 852 not taken.
✗ Branch 853 not taken.
✓ Branch 854 taken 1 times.
✓ Branch 855 taken 1 times.
✗ Branch 856 not taken.
✗ Branch 857 not taken.
✗ Branch 858 not taken.
✓ Branch 859 taken 1 times.
✗ Branch 860 not taken.
✗ Branch 861 not taken.
✗ Branch 862 not taken.
✗ Branch 863 not taken.
✓ Branch 864 taken 1 times.
✓ Branch 865 taken 1 times.
✗ Branch 866 not taken.
✗ Branch 867 not taken.
✓ Branch 868 taken 279 times.
✗ Branch 869 not taken.
✗ Branch 870 not taken.
✗ Branch 871 not taken.
✗ Branch 872 not taken.
✗ Branch 873 not taken.
✗ Branch 874 not taken.
✗ Branch 875 not taken.
✗ Branch 876 not taken.
✗ Branch 877 not taken.
✗ Branch 878 not taken.
✗ Branch 879 not taken.
✗ Branch 880 not taken.
✗ Branch 881 not taken.
✗ Branch 882 not taken.
✗ Branch 883 not taken.
✗ Branch 884 not taken.
✗ Branch 885 not taken.
✗ Branch 886 not taken.
✗ Branch 887 not taken.
✗ Branch 888 not taken.
✗ Branch 889 not taken.
✗ Branch 890 not taken.
✗ Branch 891 not taken.
✗ Branch 892 not taken.
✗ Branch 893 not taken.
✗ Branch 894 not taken.
✗ Branch 895 not taken.
✓ Branch 896 taken 1338 times.
✓ Branch 897 taken 301905 times.
✗ Branch 898 not taken.
✗ Branch 899 not taken.
✗ Branch 900 not taken.
✓ Branch 901 taken 73 times.
✗ Branch 902 not taken.
✓ Branch 903 taken 6 times.
✓ Branch 904 taken 8 times.
✓ Branch 905 taken 68 times.
✓ Branch 906 taken 10 times.
708162214 switch(scommand)
31148 {
31149 //always first
31150 case 0xFFFF: //invalid command
31151 {
31152 const char* type_str = ScriptTypeToString(type);
31153 switch(type)
31154 {
31155 case ScriptType::FFC:
31156 zprint("%s Script %s has exited.\n", type_str, ffcmap[i].scriptname.c_str()); break;
31157 case ScriptType::NPC:
31158 zprint("%s Script %s has exited.\n", type_str, npcmap[i].scriptname.c_str()); break;
31159 case ScriptType::Lwpn:
31160 zprint("%s Script %s has exited.\n", type_str, lwpnmap[i].scriptname.c_str()); break;
31161 case ScriptType::Ewpn:
31162 zprint("%s Script %s has exited.\n", type_str, ewpnmap[i].scriptname.c_str()); break;
31163 case ScriptType::ItemSprite:
31164 zprint("%s Script %s has exited.\n", type_str, itemspritemap[i].scriptname.c_str()); break;
31165 case ScriptType::Item:
31166 zprint("%s Script %s has exited.\n", type_str, itemmap[i].scriptname.c_str()); break;
31167 case ScriptType::Global:
31168 zprint("%s Script %s has exited.\n", type_str, globalmap[i].scriptname.c_str()); break;
31169 case ScriptType::Player:
31170 zprint("%s Script %s has exited.\n", type_str, playermap[i].scriptname.c_str()); break;
31171 case ScriptType::Screen:
31172 zprint("%s Script %s has exited.\n", type_str, screenmap[i].scriptname.c_str()); break;
31173 case ScriptType::OnMap:
31174 case ScriptType::DMap:
31175 case ScriptType::ActiveSubscreen:
31176 case ScriptType::PassiveSubscreen:
31177 zprint("%s Script %s has exited.\n", type_str, dmapmap[i].scriptname.c_str()); break;
31178 case ScriptType::Combo: zprint("%s Script %s has exited.\n", type_str, comboscriptmap[i].scriptname.c_str()); break;
31179
31180 default: break;
31181 }
31182 break;
31183 }
31184 case QUIT:
31185 69468 scommand = 0xFFFF;
31186 69468 break;
31187 case QUIT_NO_DEALLOC:
31188 scommand = 0xFFFF;
31189 no_dealloc = true;
31190 break;
31191
31192 case NOP: //No Operation. Do nothing. -Em
31193 break;
31194 case GOTO:
31195 {
31196 uint8_t invalid = 0;
31197 if(sarg1 < 0 )
31198 {
31199 const char* type_str = ScriptTypeToString(type);
31200 switch(type)
31201 {
31202 case ScriptType::FFC:
31203 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str(), sarg1); break;
31204 case ScriptType::NPC:
31205 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
31206 case ScriptType::Lwpn:
31207 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
31208 case ScriptType::Ewpn:
31209 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
31210 case ScriptType::ItemSprite:
31211 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
31212 case ScriptType::Item:
31213 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
31214 case ScriptType::Global:
31215 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
31216 case ScriptType::Player:
31217 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
31218 case ScriptType::Screen:
31219 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
31220 case ScriptType::OnMap:
31221 case ScriptType::DMap:
31222 case ScriptType::ActiveSubscreen:
31223 case ScriptType::PassiveSubscreen:
31224 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
31225 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
31226
31227 default: break;
31228 }
31229 invalid = 1; scommand = 0xFFFF;
31230 }
31231 if ( invalid ) break;
31232 ri->pc = sarg1;
31233 increment = false;
31234 break;
31235 }
31236 case GOTOR:
31237 {
31238 uint8_t invalid = 0;
31239 if(sarg1 < 0 )
31240 {
31241 const char* type_str = ScriptTypeToString(type);
31242 switch(type)
31243 {
31244 case ScriptType::FFC:
31245 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str() ,sarg1); break;
31246 case ScriptType::NPC:
31247 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
31248 case ScriptType::Lwpn:
31249 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
31250 case ScriptType::Ewpn:
31251 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
31252 case ScriptType::ItemSprite:
31253 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
31254 case ScriptType::Item:
31255 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
31256 case ScriptType::Global:
31257 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
31258 case ScriptType::Player:
31259 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
31260 case ScriptType::Screen:
31261 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
31262 case ScriptType::OnMap:
31263 case ScriptType::DMap:
31264 case ScriptType::ActiveSubscreen:
31265 case ScriptType::PassiveSubscreen:
31266 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
31267 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
31268
31269 default: break;
31270 }
31271 invalid = 1; scommand = 0xFFFF;
31272 }
31273 if ( invalid ) break;
31274 ri->pc = (get_register(sarg1) / 10000) - 1;
31275 increment = false;
31276 }
31277 break;
31278
31279 case GOTOTRUE:
31280 if(ri->scriptflag & TRUEFLAG)
31281 {
31282 uint8_t invalid = 0;
31283 if(sarg1 < 0 )
31284 {
31285 const char* type_str = ScriptTypeToString(type);
31286 switch(type)
31287 {
31288 case ScriptType::FFC:
31289 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str(), sarg1); break;
31290 case ScriptType::NPC:
31291 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
31292 case ScriptType::Lwpn:
31293 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
31294 case ScriptType::Ewpn:
31295 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
31296 case ScriptType::ItemSprite:
31297 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
31298 case ScriptType::Item:
31299 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
31300 case ScriptType::Global:
31301 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
31302 case ScriptType::Player:
31303 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
31304 case ScriptType::Screen:
31305 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
31306 case ScriptType::OnMap:
31307 case ScriptType::DMap:
31308 case ScriptType::ActiveSubscreen:
31309 case ScriptType::PassiveSubscreen:
31310 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
31311 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
31312
31313 default: break;
31314 }
31315 invalid = 1; scommand = 0xFFFF;
31316 }
31317 if ( invalid ) break;
31318 ri->pc = sarg1;
31319 increment = false;
31320 }
31321
31322 break;
31323
31324 case GOTOFALSE:
31325 if(!(ri->scriptflag & TRUEFLAG))
31326 {
31327 uint8_t invalid = 0;
31328 if(sarg1 < 0 )
31329 {
31330 const char* type_str = ScriptTypeToString(type);
31331 switch(type)
31332 {
31333 case ScriptType::FFC:
31334 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str(), sarg1); break;
31335 case ScriptType::NPC:
31336 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
31337 case ScriptType::Lwpn:
31338 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
31339 case ScriptType::Ewpn:
31340 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
31341 case ScriptType::ItemSprite:
31342 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
31343 case ScriptType::Item:
31344 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
31345 case ScriptType::Global:
31346 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
31347 case ScriptType::Player:
31348 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
31349 case ScriptType::Screen:
31350 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
31351 case ScriptType::OnMap:
31352 case ScriptType::DMap:
31353 case ScriptType::ActiveSubscreen:
31354 case ScriptType::PassiveSubscreen:
31355 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
31356 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
31357
31358 default: break;
31359 }
31360 invalid = 1; scommand = 0xFFFF;
31361 }
31362 if ( invalid ) break;
31363 ri->pc = sarg1;
31364 increment = false;
31365 }
31366
31367 break;
31368
31369 case GOTOMORE:
31370 if(ri->scriptflag & MOREFLAG)
31371 {
31372 uint8_t invalid = 0;
31373 if(sarg1 < 0 )
31374 {
31375 const char* type_str = ScriptTypeToString(type);
31376 switch(type)
31377 {
31378 case ScriptType::FFC:
31379 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str(), sarg1); break;
31380 case ScriptType::NPC:
31381 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
31382 case ScriptType::Lwpn:
31383 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
31384 case ScriptType::Ewpn:
31385 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
31386 case ScriptType::ItemSprite:
31387 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
31388 case ScriptType::Item:
31389 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
31390 case ScriptType::Global:
31391 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
31392 case ScriptType::Player:
31393 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
31394 case ScriptType::Screen:
31395 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
31396 case ScriptType::OnMap:
31397 case ScriptType::DMap:
31398 case ScriptType::ActiveSubscreen:
31399 case ScriptType::PassiveSubscreen:
31400 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
31401 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
31402
31403 default: break;
31404 }
31405 invalid = 1; scommand = 0xFFFF;
31406 }
31407 if ( invalid ) break;
31408 ri->pc = sarg1;
31409 increment = false;
31410 }
31411
31412 break;
31413
31414 case GOTOLESS:
31415 if(!(ri->scriptflag & MOREFLAG) || (!get_qr(qr_GOTOLESSNOTEQUAL) && (ri->scriptflag & TRUEFLAG)))
31416 {
31417 uint8_t invalid = 0;
31418 if(sarg1 < 0 )
31419 {
31420 const char* type_str = ScriptTypeToString(type);
31421 switch(type)
31422 {
31423 case ScriptType::FFC:
31424 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str(), sarg1); break;
31425 case ScriptType::NPC:
31426 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
31427 case ScriptType::Lwpn:
31428 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
31429 case ScriptType::Ewpn:
31430 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
31431 case ScriptType::ItemSprite:
31432 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
31433 case ScriptType::Item:
31434 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
31435 case ScriptType::Global:
31436 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
31437 case ScriptType::Player:
31438 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
31439 case ScriptType::Screen:
31440 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
31441 case ScriptType::OnMap:
31442 case ScriptType::DMap:
31443 case ScriptType::ActiveSubscreen:
31444 case ScriptType::PassiveSubscreen:
31445 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
31446 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
31447
31448 default: break;
31449 }
31450 invalid = 1; scommand = 0xFFFF;
31451 }
31452 if ( invalid ) break;
31453 ri->pc = sarg1;
31454 increment = false;
31455 }
31456
31457 break;
31458
31459 case LOOP:
31460 {
31461 if(get_register(sarg2) > 0)
31462 {
31463 ri->pc = sarg1;
31464 increment = false;
31465 }
31466 else
31467 {
31468 set_register(sarg1, sarg1 - 1);
31469 }
31470 }
31471 break;
31472
31473 case RETURN:
31474 {
31475 ri->pc = SH::read_stack(ri->sp) - 1;
31476 ++ri->sp;
31477 ri->sp &= MASK_SP;
31478 increment = false;
31479 break;
31480 }
31481
31482 case SETTRUE:
31483 set_register(sarg1, (ri->scriptflag & TRUEFLAG) ? 1 : 0);
31484 break;
31485
31486 case SETFALSE:
31487 set_register(sarg1, (ri->scriptflag & TRUEFLAG) ? 0 : 1);
31488 break;
31489
31490 case SETMORE:
31491 set_register(sarg1, (ri->scriptflag & MOREFLAG) ? 1 : 0);
31492 break;
31493
31494 case SETLESS:
31495 set_register(sarg1, (!(ri->scriptflag & MOREFLAG)
31496 || (ri->scriptflag & TRUEFLAG)) ? 1 : 0);
31497 break;
31498
31499 case SETTRUEI:
31500 set_register(sarg1, (ri->scriptflag & TRUEFLAG) ? 10000 : 0);
31501 break;
31502
31503 case SETFALSEI:
31504 set_register(sarg1, (ri->scriptflag & TRUEFLAG) ? 0 : 10000);
31505 break;
31506
31507 case SETMOREI:
31508 set_register(sarg1, (ri->scriptflag & MOREFLAG) ? 10000 : 0);
31509 break;
31510
31511 case SETLESSI:
31512 set_register(sarg1, (!(ri->scriptflag & MOREFLAG)
31513 || (ri->scriptflag & TRUEFLAG)) ? 10000 : 0);
31514 break;
31515
31516 case READPODARRAYR:
31517 {
31518 62707768 do_readpod(false);
31519 62707768 break;
31520 }
31521 case READPODARRAYV:
31522 {
31523 31824855 do_readpod(true);
31524 31824855 break;
31525 }
31526 case WRITEPODARRAYRR:
31527 {
31528 38172927 do_writepod(false,false);
31529 38172927 break;
31530 }
31531 case WRITEPODARRAYRV:
31532 {
31533 do_writepod(false,true);
31534 break;
31535 }
31536 case WRITEPODARRAYVR:
31537 {
31538 22050889 do_writepod(true,false);
31539 22050889 break;
31540 }
31541 case WRITEPODARRAYVV:
31542 {
31543 2928911 do_writepod(true,true);
31544 2928911 break;
31545 }
31546 case WRITEPODSTRING:
31547 {
31548 241209 do_writepodstr();
31549 241209 break;
31550 }
31551 case WRITEPODARRAY:
31552 {
31553 334 do_writepodarr();
31554 334 break;
31555 }
31556 case ZCLASS_CONSTRUCT:
31557 {
31558 do_constructclass(type,script,i);
31559 break;
31560 }
31561 case ZCLASS_READ:
31562 {
31563 do_readclass();
31564 break;
31565 }
31566 case ZCLASS_WRITE:
31567 {
31568 do_writeclass();
31569 break;
31570 }
31571 case ZCLASS_FREE:
31572 {
31573 do_freeclass();
31574 break;
31575 }
31576 case ZCLASS_OWN:
31577 {
31578 if(user_object* obj = checkObject(get_register(sarg1), true))
31579 {
31580 obj->own(type,i);
31581 }
31582 break;
31583 }
31584 case STARTDESTRUCTOR:
31585 {
31586 zprint2("STARTDESTRUCTOR: %s\n", sargstr->c_str());
31587 //This opcode's EXISTENCE indicates the first opcode
31588 //of a user_object destructor function.
31589 break;
31590 }
31591 case ZCLASS_GLOBALIZE:
31592 {
31593 if(user_object* obj = checkObject(get_register(sarg1), true))
31594 {
31595 obj->disown();
31596 }
31597 break;
31598 }
31599
31600 case NOT:
31601 do_not(false);
31602 break;
31603
31604 case COMPAREV:
31605 do_comp(true);
31606 break;
31607 case COMPAREV2:
31608 do_comp(true,true);
31609 break;
31610
31611 case COMPARER:
31612 do_comp(false);
31613 break;
31614
31615 case STRCMPR:
31616 do_internal_strcmp();
31617 break;
31618
31619 case STRICMPR:
31620 do_internal_stricmp();
31621 break;
31622
31623 case SETV:
31624 do_set(true, type, i);
31625 break;
31626
31627 case SETR:
31628 do_set(false, type, i);
31629 break;
31630
31631 case PUSHR:
31632 do_push(false);
31633 break;
31634
31635 case PUSHV:
31636 do_push(true);
31637 break;
31638
31639 case PEEK:
31640 58814 do_peek();
31641 58814 break;
31642 case POP:
31643 do_pop();
31644 break;
31645
31646 case POPARGS:
31647 do_pops();
31648 break;
31649
31650 case LOADI:
31651 do_loadi();
31652 break;
31653
31654 case STOREI:
31655 do_storei();
31656 break;
31657
31658 case LOADD:
31659 do_loadd();
31660 break;
31661
31662 case STORED:
31663 do_stored();
31664 break;
31665
31666 case LOAD1:
31667 do_loada(0);
31668 break;
31669
31670 case LOAD2:
31671 do_loada(1);
31672 break;
31673
31674 case SETA1:
31675 do_seta(0);
31676 break;
31677
31678 case SETA2:
31679 do_seta(1);
31680 break;
31681
31682 case ALLOCATEGMEMR:
31683 if(type == ScriptType::Global) do_allocatemem(false, false, type, i);
31684
31685 break;
31686
31687 case ALLOCATEGMEMV:
31688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
327 if(type == ScriptType::Global) do_allocatemem(true, false, type, i);
31689
31690 327 break;
31691
31692 case ALLOCATEMEMR:
31693 do_allocatemem(false, true, type, i);
31694 break;
31695
31696 case ALLOCATEMEMV:
31697 7021113 do_allocatemem(true, true, type, i);
31698 7021113 break;
31699
31700 case RESIZEARRAYR:
31701 do_resize_array();
31702 break;
31703 case OWNARRAYR:
31704 do_own_array(get_register(sarg1)/10000, type, i);
31705 break;
31706 case DESTROYARRAYR:
31707 do_destroy_array();
31708 break;
31709
31710 case DEALLOCATEMEMR:
31711 6996587 do_deallocatemem();
31712 6996587 break;
31713
31714 case SAVEGAMESTRUCTS:
31715 using_SRAM = 1;
31716 FFCore.do_savegamestructs(false,false);
31717 using_SRAM = 0;
31718 break;
31719 case READGAMESTRUCTS:
31720 using_SRAM = 1;
31721 FFCore.do_loadgamestructs(false,false);
31722 using_SRAM = 0;
31723 break;
31724 case ARRAYSIZE:
31725 294114413 do_arraysize();
31726 294114413 break;
31727 case ARRAYSIZEB:
31728 do_arraysize();
31729 break;
31730 case ARRAYSIZEF:
31731 do_arraysize();
31732 break;
31733 case ARRAYSIZEN:
31734 do_arraysize();
31735 break;
31736 case ARRAYSIZEI:
31737 do_arraysize();
31738 break;
31739 case ARRAYSIZEID:
31740 do_arraysize();
31741 break;
31742 case ARRAYSIZEL:
31743 do_arraysize();
31744 break;
31745 case ARRAYSIZEE:
31746 do_arraysize();
31747 break;
31748
31749 case GETFFCSCRIPT:
31750 227724 do_getffcscript();
31751 227724 break;
31752 case GETITEMSCRIPT:
31753 80 do_getitemscript();
31754 80 break;
31755
31756 case CASTBOOLI:
31757 do_boolcast(false);
31758 break;
31759
31760 case CASTBOOLF:
31761 do_boolcast(true);
31762 break;
31763
31764 case ADDV:
31765 do_add(true);
31766 break;
31767
31768 case ADDR:
31769 do_add(false);
31770 break;
31771
31772 case SUBV:
31773 do_sub(true);
31774 break;
31775 case SUBV2:
31776 do_sub(true,true);
31777 break;
31778
31779 case SUBR:
31780 do_sub(false);
31781 break;
31782
31783 case MULTV:
31784 do_mult(true);
31785 break;
31786
31787 case MULTR:
31788 do_mult(false);
31789 break;
31790
31791 case DIVV:
31792 do_div(true);
31793 break;
31794 case DIVV2:
31795 930 do_div(true,true);
31796 930 break;
31797
31798 case DIVR:
31799 do_div(false);
31800 break;
31801
31802 case MODV:
31803 do_mod(true);
31804 break;
31805 case MODV2:
31806 252 do_mod(true,true);
31807 252 break;
31808
31809 case MODR:
31810 do_mod(false);
31811 break;
31812
31813 case SINV:
31814 do_trig(true, 0);
31815 break;
31816
31817 case SINR:
31818 6163735 do_trig(false, 0);
31819 6163735 break;
31820
31821 case COSV:
31822 do_trig(true, 1);
31823 break;
31824
31825 case COSR:
31826 3204584 do_trig(false, 1);
31827 3204584 break;
31828
31829 case TANV:
31830 do_trig(true, 2);
31831 break;
31832
31833 case TANR:
31834 76 do_trig(false, 2);
31835 76 break;
31836
31837 case DEGTORAD:
31838 1263 do_degtorad();
31839 1263 break;
31840
31841 case RADTODEG:
31842 59701 do_radtodeg();
31843 59701 break;
31844
31845 case STRINGLENGTH:
31846 2629 FFCore.do_strlen(false);
31847 2629 break;
31848
31849 case ARCSINR:
31850 14918 do_asin(false);
31851 14918 break;
31852
31853 case ARCCOSR:
31854 do_acos(false);
31855 break;
31856
31857 case ARCTANR:
31858 863764 do_arctan();
31859 863764 break;
31860
31861 //Text ptr functions
31862 case FONTHEIGHTR:
31863 1259 do_fontheight();
31864 1259 break;
31865 case STRINGWIDTHR:
31866 13724 do_strwidth();
31867 13724 break;
31868 case CHARWIDTHR:
31869 37547 do_charwidth();
31870 37547 break;
31871 case MESSAGEWIDTHR:
31872 ri->d[rEXP1] = 10000* do_msgwidth(get_register(sarg1)/10000, "Text->MessageWidth()");
31873 break;
31874 case MESSAGEHEIGHTR:
31875 ri->d[rEXP1] = 10000* do_msgheight(get_register(sarg1)/10000, "Text->MessageHeight()");
31876 break;
31877 //
31878
31879 //String.h functions 2.55 Alpha 23
31880 1 case STRINGCOMPARE: FFCore.do_strcmp(); break;
31881 case STRINGICOMPARE: FFCore.do_stricmp(); break;
31882 1072 case STRINGCOPY: FFCore.do_strcpy(false,false); break;
31883 case ARRAYCOPY: FFCore.do_arraycpy(false,false); break;
31884 case STRINGNCOMPARE: FFCore.do_strncmp(); break;
31885 case STRINGNICOMPARE: FFCore.do_strnicmp(); break;
31886
31887 //More string.h functions, 19th May, 2019
31888 case XLEN: FFCore.do_xlen(false); break;
31889 case XTOI: FFCore.do_xtoi(false); break;
31890 case ILEN: FFCore.do_ilen(false); break;
31891 case ATOI: FFCore.do_atoi(false); break;
31892 case STRCSPN: FFCore.do_strcspn(); break;
31893 case STRSTR: FFCore.do_strstr(); break;
31894 case XTOA: FFCore.do_xtoa(); break;
31895 4761 case ITOA: FFCore.do_itoa(); break;
31896 case ITOACAT: FFCore.do_itoacat(); break;
31897 case STRCAT: FFCore.do_strcat(); break;
31898 case STRSPN: FFCore.do_strspn(); break;
31899 case STRCHR: FFCore.do_strchr(); break;
31900 case STRRCHR: FFCore.do_strrchr(); break;
31901 case XLEN2: FFCore.do_xlen2(); break;
31902 case XTOI2: FFCore.do_xtoi2(); break;
31903 case ILEN2: FFCore.do_ilen2(); break;
31904 case ATOI2: FFCore.do_atoi2(); break;
31905 case REMCHR2: FFCore.do_remchr2(); break;
31906 case UPPERTOLOWER: FFCore.do_UpperToLower(false); break;
31907 1 case LOWERTOUPPER: FFCore.do_LowerToUpper(false); break;
31908 case CONVERTCASE: FFCore.do_ConvertCase(false); break;
31909
31910 case GETNPCSCRIPT: FFCore.do_getnpcscript(); break;
31911 case GETCOMBOSCRIPT: FFCore.do_getcomboscript(); break;
31912 602 case GETLWEAPONSCRIPT: FFCore.do_getlweaponscript(); break;
31913 1275 case GETEWEAPONSCRIPT: FFCore.do_geteweaponscript(); break;
31914 case GETHEROSCRIPT: FFCore.do_getheroscript(); break;
31915 68 case GETGENERICSCRIPT: FFCore.do_getgenericscript(); break;
31916 case GETGLOBALSCRIPT: FFCore.do_getglobalscript(); break;
31917 105 case GETDMAPSCRIPT: FFCore.do_getdmapscript(); break;
31918 case GETSCREENSCRIPT: FFCore.do_getscreenscript(); break;
31919 31 case GETSPRITESCRIPT: FFCore.do_getitemspritescript(); break;
31920 case GETUNTYPEDSCRIPT: FFCore.do_getuntypedscript(); break;
31921 case GETSUBSCREENSCRIPT:FFCore.do_getsubscreenscript(); break;
31922 case GETNPCBYNAME: FFCore.do_getnpcbyname(); break;
31923 case GETITEMBYNAME: FFCore.do_getitembyname(); break;
31924 case GETCOMBOBYNAME: FFCore.do_getcombobyname(); break;
31925 case GETDMAPBYNAME: FFCore.do_getdmapbyname(); break;
31926
31927 case ABSR:
31928 do_abs(false);
31929 break;
31930
31931 case MINR:
31932 do_min(false);
31933 break;
31934
31935 case MINV:
31936 do_min(true);
31937 break;
31938
31939 case MAXR:
31940 do_max(false);
31941 break;
31942 case MAXV:
31943 do_max(true);
31944 break;
31945
31946 case MAXVARG:
31947 25969 FFCore.do_varg_max();
31948 25969 break;
31949 case MINVARG:
31950 71 FFCore.do_varg_min();
31951 71 break;
31952 case CHOOSEVARG:
31953 FFCore.do_varg_choose();
31954 break;
31955
31956 case PUSHVARGV:
31957 25971 do_push_varg(true);
31958 25971 break;
31959 case PUSHVARGR:
31960 31488 do_push_varg(false);
31961 31488 break;
31962
31963 case RNDR:
31964 2703958 do_rnd(false);
31965 2703958 break;
31966
31967 case RNDV:
31968 do_rnd(true);
31969 break;
31970
31971 case SRNDR:
31972 do_srnd(false);
31973 break;
31974
31975 case SRNDV:
31976 do_srnd(true);
31977 break;
31978
31979 case SRNDRND:
31980 do_srndrnd();
31981 break;
31982
31983 case GETRTCTIMER:
31984 FFCore.getRTC(false);
31985 break;
31986 case GETRTCTIMEV:
31987 FFCore.getRTC(true);
31988 break;
31989
31990 case FACTORIAL:
31991 do_factorial(false);
31992 break;
31993
31994 case SQROOTV:
31995 do_sqroot(true);
31996 break;
31997
31998 case SQROOTR:
31999 2539388 do_sqroot(false);
32000 2539388 break;
32001
32002 case POWERR:
32003 77 do_power(false);
32004 77 break;
32005 case POWERV:
32006 do_power(true);
32007 break;
32008 case POWERV2:
32009 do_power(true,true);
32010 break;
32011
32012 case LPOWERR:
32013 do_lpower(false);
32014 break;
32015 case LPOWERV:
32016 do_lpower(true);
32017 break;
32018 case LPOWERV2:
32019 do_lpower(true,true);
32020 break;
32021
32022 case IPOWERR:
32023 do_ipower(false);
32024 break;
32025
32026 case IPOWERV:
32027 do_ipower(true);
32028 break;
32029
32030 case LOG10:
32031 27 do_log10(false);
32032 27 break;
32033
32034 case LOGE:
32035 20 do_naturallog(false);
32036 20 break;
32037
32038 case ANDR:
32039 do_and(false);
32040 break;
32041
32042 case ANDV:
32043 do_and(true);
32044 break;
32045
32046 case ORR:
32047 5580675 do_or(false);
32048 5580675 break;
32049
32050 case ORV:
32051 153457 do_or(true);
32052 153457 break;
32053
32054 case XORR:
32055 191294 do_xor(false);
32056 191294 break;
32057
32058 case XORV:
32059 3 do_xor(true);
32060 3 break;
32061
32062 case NANDR:
32063 do_nand(false);
32064 break;
32065
32066 case NANDV:
32067 do_nand(true);
32068 break;
32069
32070 case NORR:
32071 do_nor(false);
32072 break;
32073
32074 case NORV:
32075 do_nor(true);
32076 break;
32077
32078 case XNORR:
32079 do_xnor(false);
32080 break;
32081
32082 case XNORV:
32083 do_xnor(true);
32084 break;
32085
32086 case BITNOT:
32087 1427960 do_bitwisenot(false);
32088 1427960 break;
32089
32090 case LSHIFTR:
32091 62330372 do_lshift(false);
32092 62330372 break;
32093
32094 case LSHIFTV:
32095 510425 do_lshift(true);
32096 510425 break;
32097
32098 case RSHIFTR:
32099 20228358 do_rshift(false);
32100 20228358 break;
32101
32102 case RSHIFTV:
32103 375777 do_rshift(true);
32104 375777 break;
32105
32106 case ANDR32:
32107 34306 do_and32(false);
32108 34306 break;
32109
32110 case ANDV32:
32111 do_and32(true);
32112 break;
32113
32114 case ORR32:
32115 17 do_or32(false);
32116 17 break;
32117
32118 case ORV32:
32119 do_or32(true);
32120 break;
32121
32122 case XORR32:
32123 do_xor32(false);
32124 break;
32125
32126 case XORV32:
32127 do_xor32(true);
32128 break;
32129
32130 case BITNOT32:
32131 do_bitwisenot32(false);
32132 break;
32133
32134 case LSHIFTR32:
32135 22 do_lshift32(false);
32136 22 break;
32137
32138 case LSHIFTV32:
32139 do_lshift32(true);
32140 break;
32141
32142 case RSHIFTR32:
32143 34296 do_rshift32(false);
32144 34296 break;
32145
32146 case RSHIFTV32:
32147 do_rshift32(true);
32148 break;
32149
32150 case TRACER:
32151 3603 FFCore.do_trace(false);
32152 3603 break;
32153
32154 case TRACELR:
32155 FFCore.do_tracel(false);
32156 break;
32157
32158 case TRACEV:
32159 FFCore.do_trace(true);
32160 break;
32161
32162 case TRACE2R:
32163 FFCore.do_tracebool(false);
32164 break;
32165
32166 //Zap and Wavy Effects
32167 case FXWAVYR:
32168 FFCore.do_fx_wavy(false);
32169 break;
32170 case FXZAPR:
32171 FFCore.do_fx_zap(false);
32172 break;
32173 //Zap and Wavy Effects
32174 case FXWAVYV:
32175 FFCore.do_fx_wavy(true);
32176 break;
32177 case FXZAPV:
32178 FFCore.do_fx_zap(true);
32179 break;
32180 case GREYSCALER:
32181 FFCore.do_greyscale(false);
32182 break;
32183 case GREYSCALEV:
32184 FFCore.do_greyscale(true);
32185 break;
32186 case MONOCHROMER:
32187 FFCore.do_monochromatic(false);
32188 break;
32189 case MONOCHROMEV:
32190 FFCore.do_monochromatic(true);
32191 break;
32192
32193 case TRACE2V:
32194 FFCore.do_tracebool(true);
32195 break;
32196
32197 case TRACE3:
32198 FFCore.do_tracenl();
32199 break;
32200
32201 case TRACE4:
32202 2 FFCore.do_cleartrace();
32203 2 break;
32204
32205 case TRACE5:
32206 1 FFCore.do_tracetobase();
32207 1 break;
32208
32209 case TRACE6:
32210 384 FFCore.do_tracestring();
32211 384 break;
32212
32213 case PRINTFV:
32214 287 FFCore.do_printf(true, false);
32215 287 break;
32216 case SPRINTFV:
32217 11645 FFCore.do_sprintf(true, false);
32218 11645 break;
32219
32220 case PRINTFVARG:
32221 3322 FFCore.do_printf(true, true);
32222 3322 break;
32223 case SPRINTFVARG:
32224 FFCore.do_sprintf(true, true);
32225 break;
32226
32227 case BREAKPOINT:
32228 if( zasm_debugger )
32229 {
32230 FFCore.do_breakpoint();
32231 }
32232 break;
32233
32234 case WARP:
32235 do_warp(true);
32236 break;
32237
32238 case WARPR:
32239 79 do_warp(false);
32240 79 break;
32241
32242 case PITWARP:
32243 do_pitwarp(true);
32244 break;
32245
32246 case PITWARPR:
32247 126 do_pitwarp(false);
32248 126 break;
32249
32250 case BREAKSHIELD:
32251 do_breakshield();
32252 break;
32253
32254 case SELECTAWPNV:
32255 do_selectweapon(true, 1);
32256 break;
32257
32258 case SELECTAWPNR:
32259 5580 do_selectweapon(false, 1);
32260 5580 break;
32261
32262 case SELECTBWPNV:
32263 do_selectweapon(true, 0);
32264 break;
32265
32266 case SELECTBWPNR:
32267 5268 do_selectweapon(false, 0);
32268 5268 break;
32269
32270 case SELECTXWPNR:
32271 do_selectweapon(false, 2);
32272 break;
32273
32274 case SELECTYWPNR:
32275 do_selectweapon(false, 3);
32276 break;
32277
32278 case PLAYSOUNDR:
32279 170815 do_sfx(false);
32280 170815 break;
32281
32282 case PLAYSOUNDV:
32283 do_sfx(true);
32284 break;
32285
32286 case ADJUSTSFXVOLUMER: FFCore.do_adjustsfxvolume(false); break;
32287 case ADJUSTSFXVOLUMEV: FFCore.do_adjustsfxvolume(true); break;
32288 case ADJUSTVOLUMER: FFCore.do_adjustvolume(false); break;
32289 case ADJUSTVOLUMEV: FFCore.do_adjustvolume(true); break;
32290
32291 case TRIGGERSECRETR:
32292 FFScript::do_triggersecret(false);
32293 break;
32294
32295 case TRIGGERSECRETV:
32296 FFScript::do_triggersecret(true);
32297 break;
32298
32299 case PLAYMIDIR:
32300 63813 do_midi(false);
32301 63813 break;
32302
32303 case PLAYMIDIV:
32304 do_midi(true);
32305 break;
32306
32307 case PLAYENHMUSIC:
32308 79 do_enh_music(false);
32309 79 break;
32310
32311 case GETMUSICFILE:
32312 100 do_get_enh_music_filename(false);
32313 100 break;
32314
32315 case GETMUSICTRACK:
32316 5 do_get_enh_music_track(false);
32317 5 break;
32318
32319 case SETDMAPENHMUSIC:
32320 3750 do_set_dmap_enh_music(false);
32321 3750 break;
32322
32323 // Audio->
32324
32325 case ENDSOUNDR:
32326 stop_sfx(false);
32327 break;
32328
32329 case ENDSOUNDV:
32330 stop_sfx(true);
32331 break;
32332
32333 case PAUSESOUNDR:
32334 pause_sfx(false);
32335 break;
32336
32337 case PAUSESOUNDV:
32338 pause_sfx(true);
32339 break;
32340
32341 case RESUMESOUNDR:
32342 resume_sfx(false);
32343 break;
32344
32345 case RESUMESOUNDV:
32346 resume_sfx(true);
32347 break;
32348
32349
32350
32351 case PAUSESFX:
32352 {
32353 int32_t sound = ri->d[rINDEX]/10000;
32354 pause_sfx(sound);
32355
32356 }
32357 break;
32358
32359 case RESUMESFX:
32360 {
32361 int32_t sound = ri->d[rINDEX]/10000;
32362 resume_sfx(sound);
32363 }
32364 break;
32365
32366 case ADJUSTSFX:
32367 {
32368 do_sfx_ex(false);
32369 }
32370 break;
32371
32372 case PLAYSOUNDEX:
32373 {
32374 do_sfx_ex(true);
32375 }
32376 break;
32377
32378 case GETSFXCOMPLETION:
32379 {
32380 do_get_sfx_completion();
32381 }
32382 break;
32383
32384 case CONTINUESFX:
32385 {
32386 int32_t sound = ri->d[rINDEX]/10000;
32387 //Backend::sfx->cont_sfx(sound);
32388
32389 //! cont_sfx was not ported to the new back end!!!
32390 // I believe this restarted the loop.
32391 resume_sfx(sound);
32392 //What was the old instruction, again? Did it exist? -Z
32393 //continue_sfx(sound);
32394 }
32395 break;
32396
32397
32398 /*
32399 case STOPITEMSOUND:
32400 void stop_item_sfx(int32_t family)
32401 */
32402
32403 // Note: these have never worked.
32404 case PAUSEMUSIC:
32405 //What was the instruction prior to adding backends?
32406 //! The pauseAll() function pauses sfx, not music, so this instruction is not doing what I intended. -Z
32407 //Check AllOff() -Z
32408 //zcmusic_pause(ZCMUSIC* zcm, int32_t pause); is in zcmusic.h
32409 // midi_paused = true;
32410 //pause_all_sfx();
32411
32412 //Backend::sfx->pauseAll();
32413 break;
32414 case RESUMEMUSIC:
32415 //What was the instruction prior to adding backends?
32416 //Check AllOff() -Z
32417 //resume_all_sfx();
32418 // midi_paused = false;
32419 //Backend::sfx->resumeAll();
32420 break;
32421
32422 //!!! typecasting
32423 case LWPNARRPTR:
32424 case EWPNARRPTR:
32425 case ITEMARRPTR:
32426 case IDATAARRPTR:
32427 case FFCARRPTR:
32428 case BOOLARRPTR:
32429 case NPCARRPTR:
32430
32431 case LWPNARRPTR2:
32432 case EWPNARRPTR2:
32433 case ITEMARRPTR2:
32434 case IDATAARRPTR2:
32435 case FFCARRPTR2:
32436 case BOOLARRPTR2:
32437 case NPCARRPTR2:
32438 FFScript::do_typedpointer_typecast(false);
32439 break;
32440
32441 case MSGSTRR:
32442 173 do_message(false);
32443 173 break;
32444
32445 case MSGSTRV:
32446 do_message(true);
32447 break;
32448
32449 case ITEMNAME:
32450 2691 do_getitemname();
32451 2691 break;
32452
32453 case NPCNAME:
32454 do_getnpcname();
32455 break;
32456
32457 case NPCDATAGETNAME:
32458 FFCore.do_getnpcdata_getname();
32459 break;
32460
32461 case GETSAVENAME:
32462 10 do_getsavename();
32463 10 break;
32464
32465 case SETSAVENAME:
32466 do_setsavename();
32467 break;
32468
32469 case GETMESSAGE:
32470 3666 do_getmessage(false);
32471 3666 break;
32472 case SETMESSAGE:
32473 do_setmessage(false);
32474 break;
32475
32476 case GETDMAPNAME:
32477 do_getdmapname(false);
32478 break;
32479
32480 case GETDMAPTITLE:
32481 701 do_getdmaptitle(false);
32482 701 break;
32483
32484 case GETDMAPINTRO:
32485 do_getdmapintro(false);
32486 break;
32487
32488 case SETDMAPNAME:
32489 do_setdmapname(false);
32490 break;
32491
32492 case SETDMAPTITLE:
32493 do_setdmaptitle(false);
32494 break;
32495
32496 case SETDMAPINTRO:
32497 do_setdmapintro(false);
32498 break;
32499
32500 case LOADLWEAPONR:
32501 1201098 do_loadlweapon(false);
32502 1201098 break;
32503
32504 case LOADLWEAPONV:
32505 do_loadlweapon(true);
32506 break;
32507
32508 case LOADEWEAPONR:
32509 2753647 do_loadeweapon(false);
32510 2753647 break;
32511
32512 case LOADEWEAPONV:
32513 do_loadeweapon(true);
32514 break;
32515
32516 case LOADITEMR:
32517 136832 do_loaditem(false);
32518 136832 break;
32519
32520 case LOADITEMV:
32521 do_loaditem(true);
32522 break;
32523
32524 case LOADITEMDATAR:
32525 1816935 do_loaditemdata(false);
32526 1816935 break;
32527
32528 //New Datatypes
32529 case LOADSHOPR:
32530 FFScript::do_loadshopdata(false);
32531 break;
32532 case LOADSHOPV:
32533 FFScript::do_loadshopdata(true);
32534 break;
32535
32536 case LOADINFOSHOPR:
32537 FFScript::do_loadinfoshopdata(false);
32538 break;
32539 case LOADINFOSHOPV:
32540 FFScript::do_loadinfoshopdata(true);
32541 break;
32542 case LOADNPCDATAR:
32543 FFScript::do_loadnpcdata(false);
32544 break;
32545 case LOADNPCDATAV:
32546 FFScript::do_loadnpcdata(true);
32547 break;
32548
32549 case LOADCOMBODATAR:
32550 25412 FFScript::do_loadcombodata(false);
32551 25412 break;
32552 case LOADCOMBODATAV:
32553 FFScript::do_loadcombodata(true);
32554 break;
32555
32556 case LOADMAPDATAR:
32557 FFScript::do_loadmapdata(false);
32558 break;
32559 case LOADMAPDATAV:
32560 FFScript::do_loadmapdata(true);
32561 break;
32562 case LOADTMPSCR:
32563 403560 FFScript::do_loadmapdata_tempscr(false);
32564 403560 break;
32565 case LOADSCROLLSCR:
32566 177544 FFScript::do_loadmapdata_scrollscr(false);
32567 177544 break;
32568
32569 case LOADSPRITEDATAR:
32570 16 FFScript::do_loadspritedata(false);
32571 16 break;
32572 case LOADSPRITEDATAV:
32573 FFScript::do_loadspritedata(true);
32574 break;
32575
32576 case LOADSCREENDATAR:
32577 FFScript::do_loadscreendata(false);
32578 break;
32579 case LOADSCREENDATAV:
32580 FFScript::do_loadscreendata(true);
32581 break;
32582
32583 case LOADBITMAPDATAR:
32584 FFScript::do_loadbitmapid(false);
32585 break;
32586
32587
32588 case LOADBITMAPDATAV:
32589 FFScript::do_loadbitmapid(true);
32590 break;
32591
32592 //functions
32593 case LOADDMAPDATAR: //command
32594 800680 FFScript::do_loaddmapdata(false); break;
32595 case LOADDMAPDATAV: //command
32596 FFScript::do_loaddmapdata(true); break;
32597 case LOADDIRECTORYR:
32598 FFCore.do_loaddirectory(); break;
32599 case LOADSTACK:
32600 FFCore.do_loadstack(); break;
32601 case CREATEPALDATA:
32602 FFCore.do_create_paldata(); break;
32603 case CREATEPALDATACLR:
32604 FFCore.do_create_paldata_clr(); break;
32605 case MIXCLR:
32606 FFCore.do_mix_clr(); break;
32607 case CREATERGBHEX:
32608 FFCore.do_create_rgb_hex(); break;
32609 case CREATERGB:
32610 FFCore.do_create_rgb(); break;
32611 case CONVERTFROMRGB:
32612 FFCore.do_convert_from_rgb(); break;
32613 case CONVERTTORGB:
32614 FFCore.do_convert_to_rgb(); break;
32615 case PALDATALOADLEVEL:
32616 FFCore.do_paldata_load_level(); break;
32617 case PALDATALOADSPRITE:
32618 FFCore.do_paldata_load_sprite(); break;
32619 case PALDATALOADMAIN:
32620 FFCore.do_paldata_load_main(); break;
32621 case PALDATALOADCYCLE:
32622 FFCore.do_paldata_load_cycle(); break;
32623 case PALDATALOADBITMAP:
32624 FFCore.do_paldata_load_bitmap(); break;
32625 case PALDATAWRITELEVEL:
32626 FFCore.do_paldata_write_level(); break;
32627 case PALDATAWRITELEVELCS:
32628 FFCore.do_paldata_write_levelcset(); break;
32629 case PALDATAWRITESPRITE:
32630 FFCore.do_paldata_write_sprite(); break;
32631 case PALDATAWRITESPRITECS:
32632 FFCore.do_paldata_write_spritecset(); break;
32633 case PALDATAWRITEMAIN:
32634 FFCore.do_paldata_write_main(); break;
32635 case PALDATAWRITEMAINCS:
32636 FFCore.do_paldata_write_maincset(); break;
32637 case PALDATAWRITECYCLE:
32638 FFCore.do_paldata_write_cycle(); break;
32639 case PALDATAWRITECYCLECS:
32640 FFCore.do_paldata_write_cyclecset(); break;
32641 case PALDATAVALIDCLR:
32642 FFCore.do_paldata_colorvalid(); break;
32643 case PALDATACLEARCLR:
32644 FFCore.do_paldata_clearcolor(); break;
32645 case PALDATACLEARCSET:
32646 FFCore.do_paldata_clearcset(); break;
32647 case PALDATAMIX:
32648 FFCore.do_paldata_mix(); break;
32649 case PALDATAMIXCS:
32650 FFCore.do_paldata_mixcset(); break;
32651 case PALDATACOPY:
32652 FFCore.do_paldata_copy(); break;
32653 case PALDATACOPYCSET:
32654 FFCore.do_paldata_copycset(); break;
32655 case PALDATAFREE:
32656 if (user_paldata* pd = checkPalData(ri->paldataref, "Free()", true))
32657 {
32658 pd->clear();
32659 }
32660 break;
32661 case PALDATAOWN:
32662 if (user_paldata* pd = checkPalData(ri->paldataref, "Own()", false))
32663 {
32664 pd->own(type, i);
32665 }
32666 break;
32667 case LOADDROPSETR: //command
32668 FFCore.do_loaddropset(false); break;
32669 case LOADRNG: //command
32670 22 FFCore.do_loadrng(); break;
32671 case LOADBOTTLETYPE: //command
32672 FFCore.do_loadbottle(false); break;
32673 case LOADBSHOPDATA: //command
32674 FFCore.do_loadbottleshop(false); break;
32675
32676 case ITEMGETDISPLAYNAME: //command
32677 item_display_name(false); break;
32678 case ITEMSETDISPLAYNAME: //command
32679 item_display_name(true); break;
32680 case ITEMGETSHOWNNAME: //command
32681 item_shown_name(); break;
32682
32683 case DMAPDATAGETNAMER: //command
32684 FFScript::do_getDMapData_dmapname(false); break;
32685 case DMAPDATAGETNAMEV: //command
32686 FFScript::do_getDMapData_dmapname(true); break;
32687
32688 case DMAPDATASETNAMER: //command
32689 FFScript::do_setDMapData_dmapname(false); break;
32690 case DMAPDATASETNAMEV: //command
32691 FFScript::do_setDMapData_dmapname(true); break;
32692
32693
32694
32695 case DMAPDATAGETTITLER: //command
32696 FFScript::do_getDMapData_dmaptitle(false); break;
32697 case DMAPDATAGETTITLEV: //command
32698 FFScript::do_getDMapData_dmaptitle(true); break;
32699 case DMAPDATASETTITLER: //command
32700 FFScript::do_setDMapData_dmaptitle(false); break;
32701 case DMAPDATASETTITLEV: //command
32702 FFScript::do_setDMapData_dmaptitle(true); break;
32703
32704
32705 case DMAPDATAGETINTROR: //command
32706 FFScript::do_getDMapData_dmapintro(false); break;
32707 case DMAPDATAGETINTROV: //command
32708 FFScript::do_getDMapData_dmapintro(true); break;
32709 case DMAPDATANSETITROR: //command
32710 FFScript::do_setDMapData_dmapintro(false); break;
32711 case DMAPDATASETINTROV: //command
32712 FFScript::do_setDMapData_dmapintro(true); break;
32713
32714
32715 case DMAPDATAGETMUSICR: //command, string to load a music file
32716 FFScript::do_getDMapData_music(false); break;
32717 case DMAPDATAGETMUSICV: //command, string to load a music file
32718 FFScript::do_getDMapData_music(true); break;
32719 case DMAPDATASETMUSICR: //command, string to load a music file
32720 FFScript::do_setDMapData_music(false); break;
32721 case DMAPDATASETMUSICV: //command, string to load a music file
32722 FFScript::do_setDMapData_music(true); break;
32723
32724 case LOADMESSAGEDATAR: //COMMAND
32725 FFScript::do_loadmessagedata(false);
32726 break;
32727 case LOADMESSAGEDATAV: //COMMAND
32728 FFScript::do_loadmessagedata(false);
32729 break;
32730
32731
32732 case MESSAGEDATASETSTRINGR: //command
32733 FFScript::do_messagedata_setstring(false);
32734 break;
32735 case MESSAGEDATASETSTRINGV: //command
32736 FFScript::do_messagedata_setstring(false);
32737 break;
32738
32739 case MESSAGEDATAGETSTRINGR: //command
32740 FFScript::do_messagedata_getstring(false);
32741 break;
32742 case MESSAGEDATAGETSTRINGV: //command
32743 FFScript::do_messagedata_getstring(false);
32744 break;
32745 case LOADITEMDATAV:
32746 do_loaditemdata(true);
32747 break;
32748
32749 case LOADNPCBYSUID:
32750 12 FFCore.do_loadnpc_by_script_uid(false);
32751 12 break;
32752
32753 case LOADLWEAPONBYSUID:
32754 598 FFCore.do_loadlweapon_by_script_uid(false);
32755 598 break;
32756
32757 case LOADWEAPONCBYSUID:
32758 FFCore.do_loadeweapon_by_script_uid(false);
32759 break;
32760
32761 case LOADNPCR:
32762 15641785 do_loadnpc(false);
32763 15641785 break;
32764
32765 case LOADNPCV:
32766 do_loadnpc(true);
32767 break;
32768
32769 case CREATELWEAPONR:
32770 77278 do_createlweapon(false);
32771 77278 break;
32772
32773 case CREATELWEAPONV:
32774 do_createlweapon(true);
32775 break;
32776
32777 case CREATEEWEAPONR:
32778 131917 do_createeweapon(false);
32779 131917 break;
32780
32781 case CREATEEWEAPONV:
32782 do_createeweapon(true);
32783 break;
32784
32785 case CREATEITEMR:
32786 21343 do_createitem(false);
32787 21343 break;
32788
32789 case CREATEITEMV:
32790 do_createitem(true);
32791 break;
32792
32793 case CREATENPCR:
32794 2363 do_createnpc(false);
32795 2363 break;
32796
32797 case CREATENPCV:
32798 do_createnpc(true);
32799 break;
32800
32801 case ISVALIDARRAY:
32802 565 do_isvalidarray();
32803 565 break;
32804
32805 case ISVALIDITEM:
32806 27033 do_isvaliditem();
32807 27033 break;
32808
32809 case ISVALIDBITMAP:
32810 10 FFCore.do_isvalidbitmap();
32811 10 break;
32812
32813 case ISALLOCATEDBITMAP:
32814 43 FFCore.do_isallocatedbitmap();
32815 43 break;
32816
32817 case ISVALIDNPC:
32818 6259830 do_isvalidnpc();
32819 6259830 break;
32820
32821 case ISVALIDLWPN:
32822 593592 do_isvalidlwpn();
32823 593592 break;
32824
32825 case ISVALIDEWPN:
32826 122622 do_isvalidewpn();
32827 122622 break;
32828
32829 case LWPNMAKEANGULAR:
32830 do_lwpnmakeangular();
32831 break;
32832
32833 case EWPNMAKEANGULAR:
32834 do_ewpnmakeangular();
32835 break;
32836
32837 case LWPNMAKEDIRECTIONAL:
32838 do_lwpnmakedirectional();
32839 break;
32840
32841 case EWPNMAKEDIRECTIONAL:
32842 do_ewpnmakedirectional();
32843 break;
32844
32845 case LWPNUSESPRITER:
32846 15079 do_lwpnusesprite(false);
32847 15079 break;
32848
32849 case LWPNUSESPRITEV:
32850 do_lwpnusesprite(true);
32851 break;
32852
32853 case EWPNUSESPRITER:
32854 132144 do_ewpnusesprite(false);
32855 132144 break;
32856
32857 case EWPNUSESPRITEV:
32858 do_ewpnusesprite(true);
32859 break;
32860
32861 case CLEARSPRITESR:
32862 do_clearsprites(false);
32863 break;
32864
32865 case CLEARSPRITESV:
32866 do_clearsprites(true);
32867 break;
32868
32869 case ISSOLID:
32870 16274661 do_issolid();
32871 16274661 break;
32872
32873 case MAPDATAISSOLID:
32874 do_mapdataissolid();
32875 break;
32876
32877 case MAPDATAISSOLIDLYR:
32878 do_mapdataissolid_layer();
32879 break;
32880
32881 case ISSOLIDLAYER:
32882 do_issolid_layer();
32883 break;
32884
32885 case SETSIDEWARP:
32886 249 do_setsidewarp();
32887 249 break;
32888
32889 case SETTILEWARP:
32890 5 do_settilewarp();
32891 5 break;
32892
32893 case GETSIDEWARPDMAP:
32894 354940 do_getsidewarpdmap(false);
32895 354940 break;
32896
32897 case GETSIDEWARPSCR:
32898 do_getsidewarpscr(false);
32899 break;
32900
32901 case GETSIDEWARPTYPE:
32902 do_getsidewarptype(false);
32903 break;
32904
32905 case GETTILEWARPDMAP:
32906 354943 do_gettilewarpdmap(false);
32907 354943 break;
32908
32909 case GETTILEWARPSCR:
32910 3 do_gettilewarpscr(false);
32911 3 break;
32912
32913 case GETTILEWARPTYPE:
32914 3 do_gettilewarptype(false);
32915 3 break;
32916
32917 case LAYERSCREEN:
32918 12696160 do_layerscreen();
32919 12696160 break;
32920
32921 case LAYERMAP:
32922 16038753 do_layermap();
32923 16038753 break;
32924
32925 case SECRETS:
32926 60 do_triggersecrets();
32927 60 break;
32928
32929 case GETSCREENFLAGS:
32930 do_getscreenflags();
32931 break;
32932
32933 case GETSCREENEFLAGS:
32934 do_getscreeneflags();
32935 break;
32936
32937 case GRAPHICSGETPIXEL:
32938 FFCore.do_graphics_getpixel();
32939 break;
32940 case GRAPHICSCOUNTCOLOR:
32941 FFCore.do_bmpcollision();
32942 break;
32943
32944 case GETSCREENDOOR:
32945 do_getscreendoor();
32946 break;
32947
32948 case GETSCREENENEMY:
32949 do_getscreennpc();
32950 break;
32951
32952 //screendata and mapdata
32953 case SETSCREENENEMY:
32954 { //void SetScreenEnemy(int32_t map, int32_t screen, int32_t index, int32_t value);
32955 int32_t map = (ri->d[rINDEX2] / 10000) - 1;
32956 int32_t scrn = ri->d[rEXP1] / 10000;
32957 int32_t index = ri->d[rINDEX] / 10000;
32958 int32_t nn = ri->d[rEXP2]/10000;
32959
32960 // int32_t x;
32961
32962 // zprint("ri->d[rEXP2] is (%i), trying to use for '%s'\n", nn, "nn");
32963 // zprint("ri->d[rEXP1] is (%i), trying to use for '%s'\n", scrn, "scrn");
32964 // zprint("ri->d[rINDEX2] is (%i), trying to use for '%s'\n", map, "map");
32965 // zprint("ri->d[rINDEX] is (%i), trying to use for '%s'\n", index, "index");
32966
32967 if(BC::checkMapID(map, "Game->SetScreenEnemy(...map...)") != SH::_NoError ||
32968 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenEnemy(...screen...)") != SH::_NoError ||
32969 BC::checkBounds(index, 0, 9, "Game->SetScreenEnemy(...index...)") != SH::_NoError)
32970 return RUNSCRIPT_ERROR;
32971
32972 // if ( BC::checkBounds(nn, 0, 2, "Game->SetScreenEnemy(...enemy...)") != SH::_NoError) x = 1;
32973 // if ( BC::checkBounds(map, 20, 21, "Game->SetScreenEnemy(...map...)") != SH::_NoError) x = 2;
32974 FFScript::set_screenenemy(&TheMaps[map * MAPSCRS + scrn], index, nn);
32975 }
32976 break;
32977
32978 case SETSCREENDOOR:
32979 { //void SetScreenDoor(int32_t map, int32_t screen, int32_t index, int32_t value);
32980 int32_t map = (ri->d[rINDEX2] / 10000) - 1;
32981 int32_t scrn = ri->d[rEXP1] / 10000;
32982 int32_t index = ri->d[rINDEX] / 10000;
32983 int32_t nn = ri->d[rEXP2]/10000;
32984
32985 if(BC::checkMapID(map, "Game->SetScreenDoor(...map...)") != SH::_NoError ||
32986 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenDoor(...screen...)") != SH::_NoError ||
32987 BC::checkBounds(index, 0, 3, "Game->SetScreenDoor(...doorindex...)") != SH::_NoError)
32988 {
32989 return RUNSCRIPT_ERROR; break;
32990 }
32991 else
32992 {
32993 FFScript::set_screendoor(&TheMaps[map * MAPSCRS + scrn], index, nn);
32994 break;
32995 }
32996
32997 }
32998
32999 case GETSCREENLAYOP:
33000 do_getscreenLayerOpacity();
33001 break;
33002 case GETSCREENSECCMB:
33003 do_getscreenSecretCombo();
33004 break;
33005 case GETSCREENSECCST:
33006 do_getscreenSecretCSet();
33007 break;
33008 case GETSCREENSECFLG:
33009 do_getscreenSecretFlag();
33010 break;
33011 case GETSCREENLAYMAP:
33012 do_getscreenLayerMap();
33013 break;
33014 case GETSCREENLAYSCR:
33015 do_getscreenLayerscreen();
33016 break;
33017 case GETSCREENPATH:
33018 do_getscreenPath();
33019 break;
33020 case GETSCREENWARPRX:
33021 do_getscreenWarpReturnX();
33022 break;
33023 case GETSCREENWARPRY:
33024 do_getscreenWarpReturnY();
33025 break;
33026
33027 case COMBOTILE:
33028 2564 do_combotile(false);
33029 2564 break;
33030
33031 case DRAWLIGHT_CIRCLE:
33032 {
33033 static const int ARGS = 7;
33034 zfix cx = zslongToFix(SH::read_stack(ri->sp + (ARGS-1)));
33035 zfix cy = zslongToFix(SH::read_stack(ri->sp + (ARGS-2)));
33036 int radius = SH::read_stack(ri->sp + (ARGS-3));
33037 int transp_rad = SH::read_stack(ri->sp + (ARGS-4));
33038 int dith_rad = SH::read_stack(ri->sp + (ARGS-5));
33039 int dith_type = SH::read_stack(ri->sp + (ARGS-6));
33040 int dith_arg = SH::read_stack(ri->sp + (ARGS-7));
33041 if(radius >= 0) radius /= 10000;
33042 else radius = game->get_light_rad();
33043 if(!radius) break;
33044 if(transp_rad >= 0) transp_rad /= 10000;
33045 if(dith_rad >= 0) dith_rad /= 10000;
33046 if(dith_type >= 0) dith_type /= 10000;
33047 if(dith_arg >= 0) dith_arg /= 10000;
33048
33049 int32_t scrolldir = FFCore.ScrollingData[SCROLLDATA_DIR];
33050 int32_t scrollxoffs = 0, scrollyoffs = 0;
33051 switch(scrolldir)
33052 {
33053 case up:
33054 scrollyoffs = -176;
33055 break;
33056 case down:
33057 scrollyoffs = 176;
33058 break;
33059 case left:
33060 scrollxoffs = -256;
33061 break;
33062 case right:
33063 scrollxoffs = 256;
33064 break;
33065 }
33066
33067 doDarkroomCircle(cx,cy,radius,darkscr_bmp_curscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
33068 doDarkroomCircle(cx+scrollxoffs,cy+scrollyoffs,radius,darkscr_bmp_scrollscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
33069 break;
33070 }
33071 case DRAWLIGHT_SQUARE:
33072 {
33073 static const int ARGS = 7;
33074 zfix cx = zslongToFix(SH::read_stack(ri->sp + (ARGS-1)));
33075 zfix cy = zslongToFix(SH::read_stack(ri->sp + (ARGS-2)));
33076 int radius = SH::read_stack(ri->sp + (ARGS-3));
33077 int transp_rad = SH::read_stack(ri->sp + (ARGS-4));
33078 int dith_rad = SH::read_stack(ri->sp + (ARGS-5));
33079 int dith_type = SH::read_stack(ri->sp + (ARGS-6));
33080 int dith_arg = SH::read_stack(ri->sp + (ARGS-7));
33081 if(radius >= 0) radius /= 10000;
33082 else radius = game->get_light_rad();
33083 if(!radius) break;
33084 if(transp_rad >= 0) transp_rad /= 10000;
33085 if(dith_rad >= 0) dith_rad /= 10000;
33086 if(dith_type >= 0) dith_type /= 10000;
33087 if(dith_arg >= 0) dith_arg /= 10000;
33088
33089 int32_t scrolldir = FFCore.ScrollingData[SCROLLDATA_DIR];
33090 int32_t scrollxoffs = 0, scrollyoffs = 0;
33091 switch(scrolldir)
33092 {
33093 case up:
33094 scrollyoffs = -176;
33095 break;
33096 case down:
33097 scrollyoffs = 176;
33098 break;
33099 case left:
33100 scrollxoffs = -256;
33101 break;
33102 case right:
33103 scrollxoffs = 256;
33104 break;
33105 }
33106
33107 doDarkroomSquare(cx,cy,radius,darkscr_bmp_curscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
33108 doDarkroomSquare(cx+scrollxoffs,cy+scrollyoffs,radius,darkscr_bmp_scrollscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
33109 break;
33110 }
33111 case DRAWLIGHT_CONE:
33112 {
33113 static const int ARGS = 8;
33114 zfix cx = zslongToFix(SH::read_stack(ri->sp + (ARGS-1)));
33115 zfix cy = zslongToFix(SH::read_stack(ri->sp + (ARGS-2)));
33116 int dir = SH::read_stack(ri->sp + (ARGS-3)) / 10000;
33117 int radius = SH::read_stack(ri->sp + (ARGS-4));
33118 int transp_rad = SH::read_stack(ri->sp + (ARGS-5));
33119 int dith_rad = SH::read_stack(ri->sp + (ARGS-6));
33120 int dith_type = SH::read_stack(ri->sp + (ARGS-7));
33121 int dith_arg = SH::read_stack(ri->sp + (ARGS-8));
33122 if(radius >= 0) radius /= 10000;
33123 else radius = game->get_light_rad()*2;
33124 if(!radius) break;
33125 if(dir < 0) break;
33126 else dir = NORMAL_DIR(dir);
33127 if(transp_rad >= 0) transp_rad /= 10000;
33128 if(dith_rad >= 0) dith_rad /= 10000;
33129 if(dith_type >= 0) dith_type /= 10000;
33130 if(dith_arg >= 0) dith_arg /= 10000;
33131
33132 int32_t scrolldir = FFCore.ScrollingData[SCROLLDATA_DIR];
33133 int32_t scrollxoffs = 0, scrollyoffs = 0;
33134 switch(scrolldir)
33135 {
33136 case up:
33137 scrollyoffs = -176;
33138 break;
33139 case down:
33140 scrollyoffs = 176;
33141 break;
33142 case left:
33143 scrollxoffs = -256;
33144 break;
33145 case right:
33146 scrollxoffs = 256;
33147 break;
33148 }
33149
33150 doDarkroomCone(cx,cy,radius,dir,darkscr_bmp_curscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
33151 doDarkroomCone(cx+scrollxoffs,cy+scrollyoffs,radius,dir,darkscr_bmp_scrollscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
33152 break;
33153 }
33154
33155 case RECTR:
33156 case CIRCLER:
33157 case ARCR:
33158 case ELLIPSER:
33159 case LINER:
33160 case PUTPIXELR:
33161 case PIXELARRAYR:
33162 case TILEARRAYR:
33163 case LINESARRAY:
33164 case COMBOARRAYR:
33165 case DRAWTILER:
33166 case DRAWTILECLOAKEDR:
33167 case DRAWCOMBOR:
33168 case DRAWCOMBOCLOAKEDR:
33169 case DRAWCHARR:
33170 case DRAWINTR:
33171 case QUADR:
33172 case TRIANGLER:
33173 case QUAD3DR:
33174 case TRIANGLE3DR:
33175 case FASTTILER:
33176 case FASTCOMBOR:
33177 case DRAWSTRINGR:
33178 case DRAWSTRINGR2:
33179 case BMPDRAWSTRINGR2:
33180 case SPLINER:
33181 case BITMAPR:
33182 case BITMAPEXR:
33183 case DRAWLAYERR:
33184 case DRAWSCREENR:
33185 case POLYGONR:
33186 case FRAMER:
33187 37361745 do_drawing_command(scommand);
33188 37361745 break;
33189
33190 case BMPRECTR:
33191 case BMPCIRCLER:
33192 case BMPARCR:
33193 case BMPELLIPSER:
33194 case BMPLINER:
33195 case BMPSPLINER:
33196 case BMPPUTPIXELR:
33197 case BMPDRAWTILER:
33198 case BMPDRAWTILECLOAKEDR:
33199 case BMPDRAWCOMBOR:
33200 case BMPDRAWCOMBOCLOAKEDR:
33201 case BMPFASTTILER:
33202 case BMPFASTCOMBOR:
33203 case BMPDRAWCHARR:
33204 case BMPDRAWINTR:
33205 case BMPDRAWSTRINGR:
33206 case BMPQUADR:
33207 case BMPQUAD3DR:
33208 case BMPTRIANGLER:
33209 case BMPTRIANGLE3DR:
33210 case BMPPOLYGONR:
33211 case BMPDRAWLAYERR:
33212 case BMPDRAWLAYERSOLIDR:
33213 case BMPDRAWLAYERCFLAGR:
33214 case BMPDRAWLAYERCTYPER:
33215 case BMPDRAWLAYERCIFLAGR:
33216 case BMPDRAWLAYERSOLIDITYR:
33217 case BMPDRAWSCREENR:
33218 case BMPDRAWSCREENSOLIDR:
33219 case BMPDRAWSCREENSOLID2R:
33220 case BMPDRAWSCREENCOMBOFR:
33221 case BMPDRAWSCREENCOMBOIR:
33222 case BMPDRAWSCREENCOMBOTR:
33223 case BITMAPGETPIXEL:
33224 case BMPBLIT:
33225 case BMPBLITTO:
33226 case BMPMODE7:
33227 case WRITEBITMAP:
33228 case CLEARBITMAP:
33229 case BITMAPCLEARTOCOLOR:
33230 case BMPFRAMER:
33231 case BMPWRITETILE:
33232 case BMPDITHER:
33233 case BMPREPLCOLOR:
33234 case BMPSHIFTCOLOR:
33235 case BMPMASKDRAW:
33236 case BMPMASKDRAW2:
33237 case BMPMASKDRAW3:
33238 case BMPMASKBLIT:
33239 case BMPMASKBLIT2:
33240 case BMPMASKBLIT3:
33241 589793 do_drawing_command(scommand);
33242 589793 break;
33243 case READBITMAP:
33244 {
33245 int32_t bitref = SH::read_stack(ri->sp+2);
33246 if(user_bitmap* b = checkBitmap(bitref,"Read()",false,true))
33247 do_drawing_command(scommand);
33248 else //If the pointer isn't allocated, attempt to allocate it first
33249 {
33250 bitref = FFCore.get_free_bitmap();
33251 ri->d[rEXP2] = bitref; //Return to ptr
33252 if(bitref) SH::write_stack(ri->sp+2,bitref); //Write the ref, for the drawing command to read
33253 else break; //No ref allocated; don't enqueue the drawing command.
33254 do_drawing_command(scommand);
33255 }
33256 break;
33257 }
33258 case REGENERATEBITMAP:
33259 {
33260 26528 ri->d[rEXP2] = SH::read_stack(ri->sp+3);
33261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26528 times.
26528 if(user_bitmap* b = checkBitmap(ri->d[rEXP2],"Create()",false,true))
33262 26528 do_drawing_command(scommand);
33263 else //If the pointer isn't allocated
33264 {
33265 int32_t w = SH::read_stack(ri->sp) / 10000;
33266 int32_t h = SH::read_stack(ri->sp+1) / 10000;
33267 if ( get_qr(qr_OLDCREATEBITMAP_ARGS) )
33268 {
33269 //flip height and width
33270 h = h ^ w;
33271 w = h ^ w;
33272 h = h ^ w;
33273 }
33274
33275 ri->d[rEXP2] = FFCore.create_user_bitmap_ex(h,w,8); //Return to ptr
33276 }
33277 26528 break;
33278 }
33279
33280 case BITMAPFREE:
33281 {
33282 3512 FFCore.do_deallocate_bitmap();
33283 3512 break;
33284 }
33285
33286 case BITMAPOWN:
33287 {
33288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
146 if(FFCore.isSystemBitref(ri->bitmapref))
33289 break; //Don't attempt to own system bitmaps!
33290 146 user_bitmap* b = checkBitmap(ri->bitmapref, "Own()", false);
33291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
146 if(b)
33292 {
33293 146 b->own(type, i);
33294 146 }
33295 146 break;
33296 }
33297
33298 case OBJ_OWN_BITMAP:
33299 {
33300 int bmpid = get_register(sarg1);
33301 if(FFCore.isSystemBitref(bmpid))
33302 break; //Don't attempt to own system bitmaps!
33303 user_bitmap* b = checkBitmap(bmpid, nullptr, false);
33304 if(!b) break;
33305 ScriptType own_type = (ScriptType)sarg2;
33306 int32_t own_i = get_own_i(own_type);
33307 b->own(own_type,own_i);
33308 break;
33309 }
33310 case OBJ_OWN_PALDATA:
33311 {
33312 int palid = get_register(sarg1);
33313 user_paldata* pd = checkPalData(palid, nullptr, false);
33314 if(!pd) break;
33315 ScriptType own_type = (ScriptType)sarg2;
33316 int32_t own_i = get_own_i(own_type);
33317 pd->own(own_type,own_i);
33318 break;
33319 }
33320 case OBJ_OWN_FILE:
33321 {
33322 int fileid = get_register(sarg1);
33323 user_file* f = checkFile(fileid, nullptr, false);
33324 if(!f) break;
33325 ScriptType own_type = (ScriptType)sarg2;
33326 int32_t own_i = get_own_i(own_type);
33327 f->own(own_type,own_i);
33328 break;
33329 }
33330 case OBJ_OWN_DIR:
33331 {
33332 int dirid = get_register(sarg1);
33333 user_dir* dr = checkDir(dirid, nullptr, false);
33334 if(!dr) break;
33335 ScriptType own_type = (ScriptType)sarg2;
33336 int32_t own_i = get_own_i(own_type);
33337 dr->own(own_type,own_i);
33338 break;
33339 }
33340 case OBJ_OWN_STACK:
33341 {
33342 int stackid = get_register(sarg1);
33343 user_stack* st = checkStack(stackid, nullptr, false);
33344 if(!st) break;
33345 ScriptType own_type = (ScriptType)sarg2;
33346 int32_t own_i = get_own_i(own_type);
33347 st->own(own_type,own_i);
33348 break;
33349 }
33350 case OBJ_OWN_RNG:
33351 {
33352 int rngid = get_register(sarg1);
33353 user_rng* r = checkRNG(rngid, nullptr, false);
33354 if(!r) break;
33355 ScriptType own_type = (ScriptType)sarg2;
33356 int32_t own_i = get_own_i(own_type);
33357 r->own(own_type,own_i);
33358 break;
33359 }
33360 case OBJ_OWN_CLASS:
33361 {
33362 int classid = get_register(sarg1);
33363 user_object* obj = checkObject(classid, false);
33364 if(!obj) break;
33365 ScriptType own_type = (ScriptType)sarg2;
33366 int32_t own_i = get_own_i(own_type);
33367 obj->own(own_type,own_i);
33368 break;
33369 }
33370 case OBJ_OWN_ARRAY:
33371 {
33372 int arrid = get_register(sarg1)/10000;
33373 ScriptType own_type = (ScriptType)sarg2;
33374 int32_t own_i = get_own_i(own_type);
33375 do_own_array(arrid, own_type, own_i);
33376 break;
33377 }
33378
33379 case COPYTILEVV:
33380 do_copytile(true, true);
33381 break;
33382
33383 case COPYTILEVR:
33384 do_copytile(true, false);
33385 break;
33386
33387 case COPYTILERV:
33388 do_copytile(false, true);
33389 break;
33390
33391 case COPYTILERR:
33392 16962076 do_copytile(false, false);
33393 16962076 break;
33394
33395 case SWAPTILEVV:
33396 do_swaptile(true, true);
33397 break;
33398
33399 case SWAPTILEVR:
33400 do_swaptile(true, false);
33401 break;
33402
33403 case SWAPTILERV:
33404 do_swaptile(false, true);
33405 break;
33406
33407 case SWAPTILERR:
33408 do_swaptile(false, false);
33409 break;
33410
33411 case CLEARTILEV:
33412 do_cleartile(true);
33413 break;
33414
33415 case CLEARTILER:
33416 do_cleartile(false);
33417 break;
33418
33419 case OVERLAYTILEVV:
33420 do_overlaytile(true, true);
33421 break;
33422
33423 case OVERLAYTILEVR:
33424 do_overlaytile(true, false);
33425 break;
33426
33427 case OVERLAYTILERV:
33428 do_overlaytile(false, true);
33429 break;
33430
33431 case OVERLAYTILERR:
33432 57032 do_overlaytile(false, false);
33433 57032 break;
33434
33435 case FLIPROTTILEVV:
33436 do_fliprotatetile(true, true);
33437 break;
33438
33439 case FLIPROTTILEVR:
33440 do_fliprotatetile(true, false);
33441 break;
33442
33443 case FLIPROTTILERV:
33444 do_fliprotatetile(false, true);
33445 break;
33446
33447 case FLIPROTTILERR:
33448 do_fliprotatetile(false, false);
33449 break;
33450
33451 case GETTILEPIXELV:
33452 do_gettilepixel(true);
33453 break;
33454
33455 case GETTILEPIXELR:
33456 do_gettilepixel(false);
33457 break;
33458
33459 case SETTILEPIXELV:
33460 do_settilepixel(true);
33461 break;
33462
33463 case SETTILEPIXELR:
33464 do_settilepixel(false);
33465 break;
33466
33467 case SHIFTTILEVV:
33468 do_shifttile(true, true);
33469 break;
33470
33471 case SHIFTTILEVR:
33472 do_shifttile(true, false);
33473 break;
33474
33475 case SHIFTTILERV:
33476 do_shifttile(false, true);
33477 break;
33478
33479 case SHIFTTILERR:
33480 do_shifttile(false, false);
33481 break;
33482
33483 case SETRENDERTARGET:
33484 3535588 do_set_rendertarget(true);
33485 3535588 break;
33486
33487 case GAMEEND:
33488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( using_SRAM )
33489 {
33490 Z_scripterrlog("Cannot End Game while reading or writing to SRAM. Aborting End. /n");
33491 break;
33492 }
33493 1 Quit = qQUIT;
33494 1 skipcont = 1;
33495 1 scommand = 0xFFFF;
33496 1 break;
33497 case GAMERELOAD:
33498 if ( using_SRAM )
33499 {
33500 Z_scripterrlog("Cannot Reload Game while reading or writing to SRAM. Aborting Reload. /n");
33501 break;
33502 }
33503 Quit = qRELOAD;
33504 skipcont = 1;
33505 scommand = 0xFFFF;
33506 break;
33507 case GAMESETCUSTOMCURSOR:
33508 {
33509 int32_t bmpptr = SH::read_stack(ri->sp + 4);
33510 int fx = SH::read_stack(ri->sp + 3) / 10000;
33511 int fy = SH::read_stack(ri->sp + 2) / 10000;
33512 bool recolor = SH::read_stack(ri->sp + 1)!=0;
33513 bool scale = SH::read_stack(ri->sp + 0)!=0;
33514 if(user_bitmap* b = checkBitmap(bmpptr,nullptr,true))
33515 {
33516 custom_mouse(b->u_bmp,fx,fy,recolor,scale);
33517 }
33518 break;
33519 }
33520
33521 case GAMECONTINUE:
33522 if ( using_SRAM )
33523 {
33524 Z_scripterrlog("Cannot Continue Game while reading or writing to SRAM. Aborting Continue. /n");
33525 break;
33526 }
33527 reset_combo_animations();
33528 reset_combo_animations2();
33529
33530 Quit = qCONT;
33531 skipcont = 1;
33532 //cont_game();
33533 scommand = 0xFFFF;
33534 break;
33535
33536 case GAMESAVEQUIT:
33537 if ( using_SRAM )
33538 {
33539 Z_scripterrlog("Cannot Save Game while reading or writing to SRAM. Aborting Save. /n");
33540 break;
33541 }
33542 Quit = qSAVE;
33543 skipcont = 1;
33544 scommand =0xFFFF;
33545 break;
33546
33547 case GAMESAVECONTINUE:
33548 Quit = qSAVECONT;
33549 skipcont = 1;
33550 scommand =0xFFFF;
33551 break;
33552
33553 case SAVE:
33554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if ( using_SRAM )
33555 {
33556 Z_scripterrlog("Cannot Save Game while reading or writing to SRAM. Aborting Save. /n");
33557 break;
33558 }
33559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(scriptCanSave)
33560 {
33561 11 save_game(false);
33562 11 scriptCanSave=false;
33563 11 }
33564 11 break;
33565
33566 case SAVESCREEN:
33567 do_showsavescreen();
33568 break;
33569
33570 case SHOWF6SCREEN:
33571 onTryQuit();
33572 break;
33573
33574 case SAVEQUITSCREEN:
33575 save_game(false, 1);
33576 break;
33577
33578 //Not Implemented
33579 case ELLIPSE2:
33580 case FLOODFILL:
33581 break;
33582
33583 case SETCOLORB:
33584 case SETDEPTHB:
33585 case GETCOLORB:
33586 case GETDEPTHB:
33587 break;
33588
33589 case ENQUEUER:
33590 do_enqueue(false);
33591 break;
33592
33593 case ENQUEUEV:
33594 do_enqueue(true);
33595 break;
33596
33597 case DEQUEUE:
33598 do_dequeue(false);
33599 break;
33600
33601 //Visual Effects
33602 case WAVYIN:
33603 FFScript::do_wavyin();
33604 break;
33605 case WAVYOUT:
33606 FFScript::do_wavyout();
33607 break;
33608 case ZAPIN:
33609 FFScript::do_zapin();
33610 break;
33611 case ZAPOUT:
33612 FFScript::do_zapout();
33613 break;
33614 case OPENWIPE:
33615 {
33616 FFScript::do_openscreen();
33617 break;
33618 }
33619 case CLOSEWIPE:
33620 {
33621 FFScript::do_closescreen();
33622 break;
33623 }
33624 case OPENWIPESHAPE:
33625 {
33626 FFScript::do_openscreenshape();
33627 break;
33628 }
33629 case CLOSEWIPESHAPE:
33630 {
33631 FFScript::do_closescreenshape();
33632 break;
33633 }
33634
33635 //Monochrome
33636 case GREYSCALEON:
33637 setMonochrome(true);
33638 break;
33639 case GREYSCALEOFF:
33640 setMonochrome(false);
33641 break;
33642
33643 case TINT:
33644 {
33645 FFCore.Tint();
33646 break;
33647 }
33648
33649 case CLEARTINT:
33650 {
33651 FFCore.clearTint();
33652 break;
33653 }
33654
33655 case MONOHUE:
33656 {
33657 FFCore.gfxmonohue();
33658 break;
33659 }
33660
33661 case SCREENDOSPAWN:
33662 {
33663 ri->d[rEXP1] = scriptloadenemies() ? 10000 : 0;
33664 break;
33665 }
33666
33667 case SCRTRIGGERCOMBO:
33668 {
33669 int32_t lyr = get_register(sarg1) / 10000;
33670 int32_t pos = get_register(sarg2) / 10000;
33671 set_register(sarg1, do_trigger_combo(lyr,pos) ? 10000 : 0);
33672 break;
33673 }
33674
33675 case SWITCHNPC:
33676 {
33677 byte effect = vbound(get_register(sarg1)/10000, 0, 255);
33678 set_register(sarg1,0);
33679 if(Hero.switchhookclk) break; //Already switching!
33680 if(GuyH::loadNPC(ri->guyref, "npc->Switch()") == SH::_NoError)
33681 {
33682 switching_object = guys.spr(GuyH::getNPCIndex(ri->guyref));
33683 hooked_combopos = -1;
33684 hooked_layerbits = 0;
33685 switching_object->switch_hooked = true;
33686 Hero.doSwitchHook(effect);
33687 set_register(sarg1,10000);
33688 }
33689 break;
33690 }
33691
33692 case SWITCHITM:
33693 {
33694 byte effect = vbound(get_register(sarg1)/10000, 0, 255);
33695 set_register(sarg1,0);
33696 if(Hero.switchhookclk) break; //Already switching!
33697 if(ItemH::loadItem(ri->itemref, "item->Switch()") == SH::_NoError)
33698 {
33699 switching_object = items.spr(ItemH::getItemIndex(ri->itemref));
33700 hooked_combopos = -1;
33701 hooked_layerbits = 0;
33702 switching_object->switch_hooked = true;
33703 Hero.doSwitchHook(effect);
33704 set_register(sarg1,10000);
33705 }
33706 break;
33707 }
33708
33709 case SWITCHLW:
33710 {
33711 byte effect = vbound(get_register(sarg1)/10000, 0, 255);
33712 set_register(sarg1,0);
33713 if(Hero.switchhookclk) break; //Already switching!
33714 if(LwpnH::loadWeapon(ri->lwpn, "lweapon->Switch()") == SH::_NoError)
33715 {
33716 switching_object = Lwpns.spr(LwpnH::getLWeaponIndex(ri->lwpn));
33717 hooked_combopos = -1;
33718 hooked_layerbits = 0;
33719 switching_object->switch_hooked = true;
33720 Hero.doSwitchHook(effect);
33721 set_register(sarg1,10000);
33722 }
33723 break;
33724 }
33725
33726 case SWITCHEW:
33727 {
33728 byte effect = vbound(get_register(sarg1)/10000, 0, 255);
33729 set_register(sarg1,0);
33730 if(Hero.switchhookclk) break; //Already switching!
33731 if(EwpnH::loadWeapon(ri->ewpn, "eweapon->Switch()") == SH::_NoError)
33732 {
33733 switching_object = Ewpns.spr(EwpnH::getEWeaponIndex(ri->lwpn));
33734 hooked_combopos = -1;
33735 hooked_layerbits = 0;
33736 switching_object->switch_hooked = true;
33737 Hero.doSwitchHook(effect);
33738 set_register(sarg1,10000);
33739 }
33740 break;
33741 }
33742
33743 case SWITCHCMB:
33744 {
33745 int32_t pos = get_register(sarg1)/10000;
33746 set_register(sarg1,0);
33747 if(Hero.switchhookclk) break; //Already switching!
33748 if(unsigned(pos) > 176)
33749 break;
33750 switching_object = NULL;
33751 hooked_combopos = pos;
33752 hooked_layerbits = 0;
33753 Hero.doSwitchHook(get_register(sarg2)/10000);
33754 if(!hooked_layerbits) //failed
33755 Hero.reset_hookshot();
33756 else set_register(sarg1,10000); //success return
33757 break;
33758 }
33759
33760 case LINKWARPEXR:
33761 {
33762 16 FFCore.do_warp_ex(false);
33763 16 break;
33764 }
33765
33766 case KILLPLAYER:
33767 {
33768 Hero.kill(get_register(sarg1));
33769 break;
33770 }
33771
33772 case HEROMOVEXY:
33773 {
33774 zfix dx = zslongToFix(SH::read_stack(ri->sp + 4));
33775 zfix dy = zslongToFix(SH::read_stack(ri->sp + 3));
33776 bool kb = SH::read_stack(ri->sp + 2)!=0;
33777 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
33778 bool shove = SH::read_stack(ri->sp + 0)!=0;
33779 ri->d[rEXP1] = Hero.movexy(dx, dy, kb, ign_sv, shove) ? 10000 : 0;
33780 break;
33781 }
33782 case HEROCANMOVEXY:
33783 {
33784 zfix dx = zslongToFix(SH::read_stack(ri->sp + 4));
33785 zfix dy = zslongToFix(SH::read_stack(ri->sp + 3));
33786 bool kb = SH::read_stack(ri->sp + 2)!=0;
33787 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
33788 bool shove = SH::read_stack(ri->sp + 0)!=0;
33789 ri->d[rEXP1] = Hero.can_movexy(dx, dy, kb, ign_sv, shove) ? 10000 : 0;
33790 break;
33791 }
33792 case HEROMOVEATANGLE:
33793 {
33794 zfix degrees = zslongToFix(SH::read_stack(ri->sp + 4));
33795 zfix pxamnt = zslongToFix(SH::read_stack(ri->sp + 3));
33796 bool kb = SH::read_stack(ri->sp + 2)!=0;
33797 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
33798 bool shove = SH::read_stack(ri->sp + 0)!=0;
33799 ri->d[rEXP1] = Hero.moveAtAngle(degrees, pxamnt, kb, ign_sv, shove) ? 10000 : 0;
33800 break;
33801 }
33802 case HEROCANMOVEATANGLE:
33803 {
33804 zfix degrees = zslongToFix(SH::read_stack(ri->sp + 4));
33805 zfix pxamnt = zslongToFix(SH::read_stack(ri->sp + 3));
33806 bool kb = SH::read_stack(ri->sp + 2)!=0;
33807 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
33808 bool shove = SH::read_stack(ri->sp + 0)!=0;
33809 ri->d[rEXP1] = Hero.can_moveAtAngle(degrees, pxamnt, kb, ign_sv, shove) ? 10000 : 0;
33810 break;
33811 }
33812 case HEROMOVE:
33813 {
33814 int dir = SH::read_stack(ri->sp + 4)/10000;
33815 zfix pxamnt = zslongToFix(SH::read_stack(ri->sp + 3));
33816 bool kb = SH::read_stack(ri->sp + 2)!=0;
33817 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
33818 bool shove = SH::read_stack(ri->sp + 0)!=0;
33819 ri->d[rEXP1] = Hero.moveDir(dir, pxamnt, kb, ign_sv, shove) ? 10000 : 0;
33820 break;
33821 }
33822 case HEROCANMOVE:
33823 {
33824 int dir = SH::read_stack(ri->sp + 4)/10000;
33825 zfix pxamnt = zslongToFix(SH::read_stack(ri->sp + 3));
33826 bool kb = SH::read_stack(ri->sp + 2)!=0;
33827 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
33828 bool shove = SH::read_stack(ri->sp + 0)!=0;
33829 ri->d[rEXP1] = Hero.can_moveDir(dir, pxamnt, kb, ign_sv, shove) ? 10000 : 0;
33830 break;
33831 }
33832 case HEROLIFTRELEASE:
33833 {
33834 if(Hero.lift_wpn)
33835 {
33836 ri->d[rEXP1] = Hero.lift_wpn->getUID();
33837 Lwpns.add(Hero.lift_wpn);
33838 Hero.lift_wpn = nullptr;
33839 }
33840 else ri->d[rEXP1] = 0;
33841 break;
33842 }
33843 case HEROLIFTGRAB:
33844 {
33845 auto lwuid = SH::read_stack(ri->sp + 2);
33846 auto lifttime = SH::read_stack(ri->sp + 1)/10000;
33847 auto liftheight = zslongToFix(SH::read_stack(ri->sp + 0));
33848 if(weapon* wpn = checkLWpn(lwuid,"Hero->Lift()"))
33849 {
33850 Hero.lift(wpn, lifttime, liftheight);
33851 if(Lwpns.find(wpn) > -1)
33852 Lwpns.remove(wpn);
33853 if(type == ScriptType::Lwpn && lwuid == i)
33854 earlyretval = RUNSCRIPT_SELFREMOVE;
33855 }
33856 break;
33857 }
33858 case LOADPORTAL:
33859 {
33860 auto val = get_register(sarg1)/10000;
33861 if(val != -1)
33862 {
33863 portal* prt = (portal*)portals.spr(val);
33864 if(prt)
33865 val = prt->getUID();
33866 else
33867 {
33868 Z_scripterrlog("Tried to load invalid portal index '%d'\n", val);
33869 val = 0;
33870 }
33871 }
33872 ri->portalref = ri->d[rEXP1] = val;
33873 break;
33874 }
33875 case CREATEPORTAL:
33876 {
33877 portal* p = new portal();
33878 if(portals.add(p))
33879 ri->portalref = ri->d[rEXP1] = p->getUID();
33880 else
33881 {
33882 ri->portalref = ri->d[rEXP1] = 0;
33883 Z_scripterrlog("Unable to create new portal! Limit reached!\n");
33884 }
33885 break;
33886 }
33887 case LOADSAVPORTAL:
33888 {
33889 auto val = get_register(sarg1)/10000;
33890 savedportal* prt = checkSavedPortal(val,"Game->LoadSavedPortal");
33891 ri->saveportalref = ri->d[rEXP1] = prt ? val : 0;
33892 break;
33893 }
33894 case CREATESAVPORTAL:
33895 {
33896 if(game->user_portals.size() >= MAX_SAVED_PORTALS)
33897 {
33898 ri->saveportalref = ri->d[rEXP1] = 0;
33899 Z_scripterrlog("Cannot create any more Saved Portals! Remove some first!\n");
33900 break;
33901 }
33902 savedportal& ref = game->user_portals.emplace_back();
33903 ri->saveportalref = ri->d[rEXP1] = ref.getUID();
33904 break;
33905 }
33906 case PORTALREMOVE:
33907 {
33908 if(portal* p = checkPortal(ri->portalref, "Remove", true))
33909 {
33910 if(p == &mirror_portal)
33911 p->clear();
33912 else
33913 {
33914 auto id = portals.find(p);
33915 if(id > -1)
33916 portals.del(id,true);
33917 }
33918 }
33919 break;
33920 }
33921 case PORTALUSESPRITE:
33922 do_portalusesprite();
33923 break;
33924 case SAVEDPORTALREMOVE:
33925 {
33926 if(savedportal* sp = checkSavedPortal(ri->saveportalref, "Remove", true))
33927 {
33928 if(sp == &(game->saved_mirror_portal))
33929 sp->clear();
33930 else
33931 {
33932 //ensure all pointers to the object are cleared before deleting
33933 portals.forEach([&](sprite& spr)
33934 {
33935 portal* tmp = (portal*)&spr;
33936 if(sp->getUID() == tmp->saved_data)
33937 {
33938 tmp->saved_data = 0;
33939 }
33940 return false;
33941 });
33942 //delete the savedportal object from the vector
33943 for(auto it = game->user_portals.begin();
33944 it != game->user_portals.end();)
33945 {
33946 savedportal& tmp = *it;
33947 if(sp == &tmp)
33948 {
33949 game->user_portals.erase(it);
33950 break;
33951 }
33952 else ++it;
33953 }
33954 }
33955 }
33956 break;
33957 }
33958 case SAVEDPORTALGENERATE:
33959 {
33960 auto retval = 0;
33961 if(savedportal* sp = checkSavedPortal(ri->saveportalref, "Generate"))
33962 {
33963 retval = getPortalFromSaved(sp);
33964 if(!retval)
33965 {
33966 if(portal* p = loadportal(*sp))
33967 if(portals.add(p))
33968 retval = p->getUID();
33969 }
33970 }
33971 ri->d[rEXP1] = retval;
33972 break;
33973 }
33974
33975 case LINKEXPLODER:
33976 {
33977 int32_t mode = get_register(sarg1) / 10000;
33978 if ( (unsigned) mode > 2 )
33979 {
33980 Z_scripterrlog("Invalid mode (%d) passed to Player->Explode(int32_t mode)\n",mode);
33981 }
33982 else Hero.explode(mode);
33983 break;
33984 }
33985 case NPCEXPLODER:
33986 {
33987
33988 int32_t mode = get_register(sarg1) / 10000;
33989 al_trace("Called npc->Explode(%d), for enemy index %u\n", mode, ri->guyref);
33990 if ( (unsigned) mode > 2 )
33991 {
33992 Z_scripterrlog("Invalid mode (%d) passed to npc->Explode(int32_t mode)\n",mode);
33993 }
33994 else
33995 {
33996 if(GuyH::loadNPC(ri->guyref, "npc->Explode()") == SH::_NoError)
33997 {
33998 al_trace("npc->Explode() is loading the npc into a pointer.\n");
33999 //enemy *e = (enemy*)guys.spr(ri->guyref);
34000 al_trace("npc->Explode() is calling enemy::explode.\n");
34001 //(enemy *) guys.explode(eid);
34002 //e->explode(mode);
34003 //enemy *en=GuyH::getNPC();
34004 //en->stop_bgsfx(GuyH::getNPCIndex(ri->guyref));
34005 guys.spr(GuyH::getNPCIndex(ri->guyref))->explode(mode);
34006 }
34007 }
34008 break;
34009 }
34010
34011 case ITEMEXPLODER:
34012 {
34013
34014 int32_t mode = get_register(sarg1) / 10000;
34015 al_trace("Called item->Explode(%d), for item index %u\n", mode, ri->itemref);
34016 if ( (unsigned) mode > 2 )
34017 {
34018 Z_scripterrlog("Invalid mode (%d) passed to item->Explode(int32_t mode)\n",mode);
34019 }
34020 else
34021 {
34022 if(ItemH::loadItem(ri->itemref, "item->Explode()") == SH::_NoError)
34023 {
34024 items.spr(ItemH::getItemIndex(ri->itemref))->explode(mode);
34025 }
34026 }
34027 break;
34028 }
34029 case LWEAPONEXPLODER:
34030 {
34031
34032 int32_t mode = get_register(sarg1) / 10000;
34033 al_trace("Called lweapon->Explode(%d), for lweapon index %u\n", mode, ri->lwpn);
34034 if ( (unsigned) mode > 2 )
34035 {
34036 Z_scripterrlog("Invalid mode (%d) passed to lweapon->Explode(int32_t mode)\n",mode);
34037 }
34038 else
34039 {
34040 if(LwpnH::loadWeapon(ri->lwpn, "lweapon->Explode()") == SH::_NoError)
34041 {
34042 Lwpns.spr(LwpnH::getLWeaponIndex(ri->lwpn))->explode(mode);
34043 }
34044 }
34045 break;
34046 }
34047 case EWEAPONEXPLODER:
34048 {
34049
34050 int32_t mode = get_register(sarg1) / 10000;
34051 al_trace("Called eweapon->Explode(%d), for eweapon index %u\n", mode, ri->ewpn);
34052 if ( (unsigned) mode > 2 )
34053 {
34054 Z_scripterrlog("Invalid mode (%d) passed to eweapon->Explode(int32_t mode)\n",mode);
34055 }
34056 else
34057 {
34058 if(EwpnH::loadWeapon(ri->ewpn, "eweapon->Explode()") == SH::_NoError)
34059 {
34060 Ewpns.spr(EwpnH::getEWeaponIndex(ri->lwpn))->explode(mode);
34061 }
34062 }
34063 break;
34064 }
34065
34066 case BOTTLENAMEGET:
34067 {
34068 int32_t arrayptr = get_register(sarg1) / 10000;
34069 int32_t id = ri->bottletyperef-1;
34070 if(unsigned(id) > 63)
34071 {
34072 Z_scripterrlog("Invalid bottledata ID (%d) passed to bottledata->GetName().\n", id);
34073 break;
34074 }
34075
34076 if(ArrayH::setArray(arrayptr, QMisc.bottle_types[id].name) == SH::_Overflow)
34077 Z_scripterrlog("Array supplied to 'bottledata->GetName()' not large enough\n");
34078 break;
34079 }
34080 case BOTTLENAMESET:
34081 {
34082 int32_t arrayptr = get_register(sarg1) / 10000;
34083 int32_t id = ri->bottletyperef-1;
34084 if(unsigned(id) > 63)
34085 {
34086 Z_scripterrlog("Invalid bottledata ID (%d) passed to bottledata->SetName().\n", id+1);
34087 break;
34088 }
34089 string name;
34090 ArrayH::getString(arrayptr, name, 31);
34091 strcpy(QMisc.bottle_types[id].name, name.c_str());
34092 break;
34093 }
34094 case BSHOPNAMEGET:
34095 {
34096 int32_t arrayptr = get_register(sarg1) / 10000;
34097 int32_t id = ri->bottleshopref-1;
34098 if(unsigned(id) > 255)
34099 {
34100 Z_scripterrlog("Invalid bottleshopdata ID (%d) passed to bottleshopdata->GetName().\n", id+1);
34101 break;
34102 }
34103
34104 if(ArrayH::setArray(arrayptr, QMisc.bottle_shop_types[id].name) == SH::_Overflow)
34105 Z_scripterrlog("Array supplied to 'bottleshopdata->GetName()' not large enough\n");
34106 break;
34107 }
34108 case BSHOPNAMESET:
34109 {
34110 int32_t arrayptr = get_register(sarg1) / 10000;
34111 int32_t id = ri->bottleshopref;
34112 if(unsigned(id) > 255)
34113 {
34114 Z_scripterrlog("Invalid bottleshopdata ID (%d) passed to bottleshopdata->SetName().\n", id);
34115 break;
34116 }
34117 string name;
34118 ArrayH::getString(arrayptr, name, 31);
34119 strcpy(QMisc.bottle_shop_types[id].name, name.c_str());
34120 break;
34121 }
34122
34123 case RUNITEMSCRIPT:
34124 {
34125 15 int32_t itemid = ri->idata;
34126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(unsigned(itemid) > MAXITEMS) break;
34127 15 int32_t mode = get_register(sarg1) / 10000;
34128 // zprint("Trying to run the script on item: %d\n",itemid);
34129 // zprint("The script ID is: %d\n",itemsbuf[itemid].script);
34130 // zprint("Runitemscript mode is: %d\n", mode);
34131 15 auto& data = get_script_engine_data(ScriptType::Item, itemid);
34132
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
15 switch(mode)
34133 {
34134 case 0:
34135 {
34136 data.doscript = 4;
34137 break;
34138 }
34139 case 1:
34140 {
34141 if ( itemsbuf[itemid].script != 0 ) //&& !data.doscript )
34142 {
34143 if ( !data.doscript )
34144 {
34145 data.ref.Clear();
34146 data.doscript = 1;
34147 //ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[itemid].script, itemid);
34148 }
34149 else
34150 {
34151 //Emily, clear the stack here, clear refinfo, and set up to run again on the next frame from the beginning.
34152 }
34153 }
34154 break;
34155 }
34156 15 case 2:
34157 default:
34158 {
34159
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if ( itemsbuf[itemid].script != 0 ) //&& !data.doscript )
34160 {
34161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if (data.doscript != 2 )data.doscript = 2;
34162 15 }
34163 15 break;
34164 }
34165 /*
34166 case 0:
34167 {
34168 data.doscript = 0;
34169 break;
34170 }
34171 default:
34172 {
34173
34174 if ( itemsbuf[itemid].script != 0 ) //&& !data.doscript )
34175 {
34176 //itemScriptData[itemid].Clear();
34177 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[itemid][q] = 0;
34178 //ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[itemid].script, itemid & 0xFFF);
34179 data.doscript = 2;
34180 }
34181 break;
34182 }
34183 */
34184 }
34185 15 break;
34186 }
34187
34188 //case NPCData
34189
34190 case GETNPCDATATILE: FFScript::getNPCData_tile(); break;
34191 case GETNPCDATAEHEIGHT: FFScript::getNPCData_e_height(); break;
34192 case GETNPCDATAFLAGS: FFScript::getNPCData_flags(); break;
34193 case GETNPCDATAFLAGS2: FFScript::getNPCData_flags2(); break;
34194 case GETNPCDATAWIDTH: FFScript::getNPCData_flags2(); break;
34195 case GETNPCDATAHEIGHT: FFScript::getNPCData_flags2(); break;
34196 case GETNPCDATASTILE: FFScript::getNPCData_s_tile(); break;
34197 case GETNPCDATASWIDTH: FFScript::getNPCData_s_width(); break;
34198 case GETNPCDATASHEIGHT: FFScript::getNPCData_s_height(); break;
34199 case GETNPCDATAETILE: FFScript::getNPCData_e_tile(); break;
34200 case GETNPCDATAEWIDTH: FFScript::getNPCData_e_width(); break;
34201 case GETNPCDATAHP: FFScript::getNPCData_hp(); break;
34202 case GETNPCDATAFAMILY: FFScript::getNPCData_family(); break;
34203 case GETNPCDATACSET: FFScript::getNPCData_cset(); break;
34204 case GETNPCDATAANIM: FFScript::getNPCData_anim(); break;
34205 case GETNPCDATAEANIM: FFScript::getNPCData_e_anim(); break;
34206 case GETNPCDATAFRAMERATE: FFScript::getNPCData_frate(); break;
34207 case GETNPCDATAEFRAMERATE: FFScript::getNPCData_e_frate(); break;
34208 case GETNPCDATATOUCHDMG: FFScript::getNPCData_dp(); break;
34209 case GETNPCDATAWPNDAMAGE: FFScript::getNPCData_wdp(); break;
34210 case GETNPCDATAWEAPON: FFScript::getNPCData_wdp(); break;
34211 case GETNPCDATARANDOM: FFScript::getNPCData_rate(); break;
34212 case GETNPCDATAHALT: FFScript::getNPCData_hrate(); break;
34213 case GETNPCDATASTEP: FFScript::getNPCData_step(); break;
34214 case GETNPCDATAHOMING: FFScript::getNPCData_homing(); break;
34215 case GETNPCDATAHUNGER: FFScript::getNPCData_grumble(); break;
34216 case GETNPCDATADROPSET: FFScript::getNPCData_item_set(); break;
34217 case GETNPCDATABGSFX: FFScript::getNPCData_bgsfx(); break;
34218 case GETNPCDATADEATHSFX: FFScript::getNPCData_deadsfx(); break;
34219 case GETNPCDATAXOFS: FFScript::getNPCData_xofs(); break;
34220 case GETNPCDATAYOFS: FFScript::getNPCData_yofs(); break;
34221 case GETNPCDATAZOFS: FFScript::getNPCData_zofs(); break;
34222 case GETNPCDATAHXOFS: FFScript::getNPCData_hxofs(); break;
34223 case GETNPCDATAHYOFS: FFScript::getNPCData_hyofs(); break;
34224 case GETNPCDATAHITWIDTH: FFScript::getNPCData_hxsz(); break;
34225 case GETNPCDATAHITHEIGHT: FFScript::getNPCData_hysz(); break;
34226 case GETNPCDATAHITZ: FFScript::getNPCData_hzsz(); break;
34227 case GETNPCDATATILEWIDTH: FFScript::getNPCData_txsz(); break;
34228 case GETNPCDATATILEHEIGHT: FFScript::getNPCData_tysz(); break;
34229 case GETNPCDATAWPNSPRITE: FFScript::getNPCData_wpnsprite(); break;
34230 //case GETNPCDATASCRIPTDEF: FFScript::getNPCData_scriptdefence(); break; //2.future cross-compat.
34231 case GETNPCDATADEFENSE: FFScript::getNPCData_defense(); break;
34232 case GETNPCDATASIZEFLAG: FFScript::getNPCData_SIZEflags(); break;
34233 case GETNPCDATAATTRIBUTE: FFScript::getNPCData_misc(); break;
34234 case GETNPCDATAHITSFX: FFScript::getNPCData_hitsfx(); break;
34235
34236 case SETNPCDATAFLAGS: FFScript::setNPCData_flags(); break;
34237 case SETNPCDATAFLAGS2: FFScript::setNPCData_flags2(); break;
34238 case SETNPCDATAWIDTH: FFScript::setNPCData_width(); break;
34239 case SETNPCDATAHEIGHT: FFScript::setNPCData_height(); break;
34240 case SETNPCDATASTILE: FFScript::setNPCData_s_tile(); break;
34241 case SETNPCDATASWIDTH: FFScript::setNPCData_s_width(); break;
34242 case SETNPCDATASHEIGHT: FFScript::setNPCData_s_height(); break;
34243 case SETNPCDATAETILE: FFScript::setNPCData_e_tile(); break;
34244 case SETNPCDATAEWIDTH: FFScript::setNPCData_e_width(); break;
34245 case SETNPCDATAHP: FFScript::setNPCData_hp(); break;
34246 case SETNPCDATAFAMILY: FFScript::setNPCData_family(); break;
34247 case SETNPCDATACSET: FFScript::setNPCData_cset(); break;
34248 case SETNPCDATAANIM: FFScript::setNPCData_anim(); break;
34249 case SETNPCDATAEANIM: FFScript::setNPCData_e_anim(); break;
34250 case SETNPCDATAFRAMERATE: FFScript::setNPCData_frate(); break;
34251 case SETNPCDATAEFRAMERATE: FFScript::setNPCData_e_frate(); break;
34252 case SETNPCDATATOUCHDMG: FFScript::setNPCData_dp(); break;
34253 case SETNPCDATAWPNDAMAGE: FFScript::setNPCData_wdp(); break;
34254 case SETNPCDATAWEAPON: FFScript::setNPCData_weapon(); break;
34255 case SETNPCDATARANDOM: FFScript::setNPCData_rate(); break;
34256 case SETNPCDATAHALT: FFScript::setNPCData_hrate(); break;
34257 case SETNPCDATASTEP: FFScript::setNPCData_step(); break;
34258 case SETNPCDATAHOMING: FFScript::setNPCData_homing(); break;
34259 case SETNPCDATAHUNGER: FFScript::setNPCData_grumble(); break;
34260 case SETNPCDATADROPSET: FFScript::setNPCData_item_set(); break;
34261 case SETNPCDATABGSFX: FFScript::setNPCData_bgsfx(); break;
34262 case SETNPCDATADEATHSFX: FFScript::setNPCData_hitsfx(); break;
34263 case SETNPCDATAXOFS: FFScript::setNPCData_xofs(); break;
34264 case SETNPCDATAYOFS: FFScript::setNPCData_yofs(); break;
34265 case SETNPCDATAZOFS: FFScript::setNPCData_zofs(); break;
34266 case SETNPCDATAHXOFS: FFScript::setNPCData_hxofs(); break;
34267 case SETNPCDATAHYOFS: FFScript::setNPCData_hyofs(); break;
34268 case SETNPCDATAHITWIDTH: FFScript::setNPCData_hxsz(); break;
34269 case SETNPCDATAHITHEIGHT: FFScript::setNPCData_hysz(); break;
34270 case SETNPCDATAHITZ: FFScript::setNPCData_hzsz(); break;
34271 case SETNPCDATATILEWIDTH: FFScript::setNPCData_txsz(); break;
34272 case SETNPCDATATILEHEIGHT: FFScript::setNPCData_tysz(); break;
34273 case SETNPCDATAWPNSPRITE: FFScript::setNPCData_wpnsprite(); break;
34274 case SETNPCDATAHITSFX: FFScript::setNPCData_hitsfx(); break;
34275 case SETNPCDATATILE: FFScript::setNPCData_tile(); break;
34276 case SETNPCDATAEHEIGHT: FFScript::setNPCData_e_height(); break;
34277
34278
34279
34280
34281
34282
34283 //case SETNPCDATASCRIPTDEF : FFScript::setNPCData_scriptdefence(); break;
34284 case SETNPCDATADEFENSE : FFScript::setNPCData_defense(ri->d[rEXP1]); break;
34285 case SETNPCDATASIZEFLAG : FFScript::setNPCData_SIZEflags(ri->d[rEXP1]); break;
34286 case SETNPCDATAATTRIBUTE : FFScript::setNPCData_misc(ri->d[rEXP1]); break;
34287
34288
34289 //ComboData
34290
34291 case GCDBLOCKENEM: FFScript::getComboData_block_enemies(); break;
34292 case GCDBLOCKHOLE: FFScript::getComboData_block_hole(); break;
34293 case GCDBLOCKTRIG: FFScript::getComboData_block_trigger(); break;
34294 case GCDCONVEYSPDX: FFScript::getComboData_conveyor_x_speed(); break;
34295 case GCDCONVEYSPDY: FFScript::getComboData_conveyor_y_speed(); break;
34296 case GCDCREATEENEM: FFScript::getComboData_create_enemy(); break;
34297 case GCDCREATEENEMWH: FFScript::getComboData_create_enemy_when(); break;
34298 case GCDCREATEENEMCH: FFScript::getComboData_create_enemy_change(); break;
34299 case GCDDIRCHTYPE: FFScript::getComboData_directional_change_type(); break;
34300 case GCDDISTCHTILES: FFScript::getComboData_distance_change_tiles(); break;
34301 case GCDDIVEITEM: FFScript::getComboData_dive_item(); break;
34302 case GCDDOCK: FFScript::getComboData_dock(); break;
34303 case GCDFAIRY: FFScript::getComboData_fairy(); break;
34304 case GCDFFCOMBOATTRIB: FFScript::getComboData_ff_combo_attr_change(); break;
34305 case GCDFOOTDECOTILE: FFScript::getComboData_foot_decorations_tile(); break;
34306 case GCDFOOTDECOTYPE: FFScript::getComboData_foot_decorations_type(); break;
34307 case GCDHOOKSHOTGRAB: FFScript::getComboData_hookshot_grab_point(); break;
34308 case GCDLADDERPASS: FFScript::getComboData_ladder_pass(); break;
34309 case GCDLOCKBLOCKTYPE: FFScript::getComboData_lock_block_type(); break;
34310 case GCDLOCKBLOCKCHANGE: FFScript::getComboData_lock_block_change(); break;
34311 case GCDMAGICMIRRORTYPE: FFScript::getComboData_magic_mirror_type(); break;
34312 case GCDMODIFYHPAMOUNT: FFScript::getComboData_modify_hp_amount(); break;
34313 case GCDMODIFYHPDELAY: FFScript::getComboData_modify_hp_delay(); break;
34314 case GCDMODIFYHPTYPE: FFScript::getComboData_modify_hp_type(); break;
34315 case GCDMODIFYMPAMOUNT: FFScript::getComboData_modify_mp_amount(); break;
34316 case GCDMODIFYMPDELAY: FFScript::getComboData_modify_mp_delay(); break;
34317 case GCDMODIFYMPTYPE: FFScript::getComboData_modify_mp_type(); break;
34318 case GCDNOPUSHBLOCKS: FFScript::getComboData_no_push_blocks(); break;
34319 case GCDOVERHEAD: FFScript::getComboData_overhead(); break;
34320 case GCDPLACEENEMY: FFScript::getComboData_place_enemy(); break;
34321 case GCDPUSHDIR: FFScript::getComboData_push_direction(); break;
34322 case GCDPUSHWEIGHT: FFScript::getComboData_push_weight(); break;
34323 case GCDPUSHWAIT: FFScript::getComboData_push_wait(); break;
34324 case GCDPUSHED: FFScript::getComboData_pushed(); break;
34325 case GCDRAFT: FFScript::getComboData_raft(); break;
34326 case GCDRESETROOM: FFScript::getComboData_reset_room(); break;
34327 case GCDSAVEPOINT: FFScript::getComboData_save_point_type(); break;
34328 case GCDSCREENFREEZE: FFScript::getComboData_screen_freeze_type(); break;
34329 case GCDSECRETCOMBO: FFScript::getComboData_secret_combo(); break;
34330 case GCDSINGULAR: FFScript::getComboData_singular(); break;
34331 case GCDSLOWMOVE: FFScript::getComboData_slow_movement(); break;
34332 case GCDSTATUE: FFScript::getComboData_statue_type(); break;
34333 case GCDSTEPTYPE: FFScript::getComboData_step_type(); break;
34334 case GCDSTEPCHANGETO: FFScript::getComboData_step_change_to(); break;
34335 case GCDSTRIKEREMNANTS: FFScript::getComboData_strike_remnants(); break;
34336 case GCDSTRIKEREMNANTSTYPE: FFScript::getComboData_strike_remnants_type(); break;
34337 case GCDSTRIKECHANGE: FFScript::getComboData_strike_change(); break;
34338 case GCDSTRIKECHANGEITEM: FFScript::getComboData_strike_item(); break;
34339 case GCDTOUCHITEM: FFScript::getComboData_touch_item(); break;
34340 case GCDTOUCHSTAIRS: FFScript::getComboData_touch_stairs(); break;
34341 case GCDTRIGGERTYPE: FFScript::getComboData_trigger_type(); break;
34342 case GCDTRIGGERSENS: FFScript::getComboData_trigger_sensitive(); break;
34343 case GCDWARPTYPE: FFScript::getComboData_warp_type(); break;
34344 case GCDWARPSENS: FFScript::getComboData_warp_sensitive(); break;
34345 case GCDWARPDIRECT: FFScript::getComboData_warp_direct(); break;
34346 case GCDWARPLOCATION: FFScript::getComboData_warp_location(); break;
34347 case GCDWATER: FFScript::getComboData_water(); break;
34348 case GCDWHISTLE: FFScript::getComboData_whistle(); break;
34349 case GCDWINGAME: FFScript::getComboData_win_game(); break;
34350 case GCDBLOCKWEAPLVL: FFScript::getComboData_block_weapon_lvl(); break;
34351 case GCDTILE: FFScript::getComboData_tile(); break;
34352 case GCDFLIP: FFScript::getComboData_flip(); break;
34353 case GCDWALK: FFScript::getComboData_walk(); break;
34354 case GCDTYPE: FFScript::getComboData_type(); break;
34355 case GCDCSETS: FFScript::getComboData_csets(); break;
34356 case GCDFOO: break;
34357 case GCDFRAMES: FFScript::getComboData_frames(); break;
34358 case GCDSPEED: FFScript::getComboData_speed(); break;
34359 case GCDNEXTCOMBO: FFScript::getComboData_nextcombo(); break;
34360 case GCDNEXTCSET: FFScript::getComboData_nextcset(); break;
34361 case GCDFLAG: FFScript::getComboData_flag(); break;
34362 case GCDSKIPANIM: FFScript::getComboData_skipanim(); break;
34363 case GCDNEXTTIMER: FFScript::getComboData_nexttimer(); break;
34364 case GCDSKIPANIMY: FFScript::getComboData_skipanimy(); break;
34365 case GCDANIMFLAGS: FFScript::getComboData_animflags(); break;
34366 case GCDBLOCKWEAPON: FFScript::getComboData_block_weapon(); break;
34367 case GCDEXPANSION: FFScript::getComboData_expansion(); break;
34368 case GCDSTRIKEWEAPONS: FFScript::getComboData_strike_weapons(); break;
34369 case SCDBLOCKENEM: FFScript::setComboData_block_enemies(); break;
34370 case SCDBLOCKHOLE: FFScript::setComboData_block_hole(); break;
34371 case SCDBLOCKTRIG: FFScript::setComboData_block_trigger(); break;
34372 case SCDCONVEYSPDX: FFScript::setComboData_conveyor_x_speed(); break;
34373 case SCDCONVEYSPDY: FFScript::setComboData_conveyor_y_speed(); break;
34374 case SCDCREATEENEM: FFScript::setComboData_create_enemy(); break;
34375 case SCDCREATEENEMWH: FFScript::setComboData_create_enemy_when(); break;
34376 case SCDCREATEENEMCH: FFScript::setComboData_create_enemy_change(); break;
34377 case SCDDIRCHTYPE: FFScript::setComboData_directional_change_type(); break;
34378 case SCDDISTCHTILES: FFScript::setComboData_distance_change_tiles(); break;
34379 case SCDDIVEITEM: FFScript::setComboData_dive_item(); break;
34380 case SCDDOCK: FFScript::setComboData_dock(); break;
34381 case SCDFAIRY: FFScript::setComboData_fairy(); break;
34382 case SCDFFCOMBOATTRIB: FFScript::setComboData_ff_combo_attr_change(); break;
34383 case SCDFOOTDECOTILE: FFScript::setComboData_foot_decorations_tile(); break;
34384 case SCDFOOTDECOTYPE: FFScript::setComboData_foot_decorations_type(); break;
34385 case SCDHOOKSHOTGRAB: FFScript::setComboData_hookshot_grab_point(); break;
34386 case SCDLADDERPASS: FFScript::setComboData_ladder_pass(); break;
34387 case SCDLOCKBLOCKTYPE: FFScript::setComboData_lock_block_type(); break;
34388 case SCDLOCKBLOCKCHANGE: FFScript::setComboData_lock_block_change(); break;
34389 case SCDMAGICMIRRORTYPE: FFScript::setComboData_magic_mirror_type(); break;
34390 case SCDMODIFYHPAMOUNT: FFScript::setComboData_modify_hp_amount(); break;
34391 case SCDMODIFYHPDELAY: FFScript::setComboData_modify_hp_delay(); break;
34392 case SCDMODIFYHPTYPE: FFScript::setComboData_modify_hp_type(); break;
34393 case SCDMODIFYMPAMOUNT: FFScript::setComboData_modify_mp_amount(); break;
34394 case SCDMODIFYMPDELAY: FFScript::setComboData_modify_mp_delay(); break;
34395 case SCDMODIFYMPTYPE: FFScript::setComboData_modify_mp_type(); break;
34396 case SCDNOPUSHBLOCKS: FFScript::setComboData_no_push_blocks(); break;
34397 case SCDOVERHEAD: FFScript::setComboData_overhead(); break;
34398 case SCDPLACEENEMY: FFScript::setComboData_place_enemy(); break;
34399 case SCDPUSHDIR: FFScript::setComboData_push_direction(); break;
34400 case SCDPUSHWEIGHT: FFScript::setComboData_push_weight(); break;
34401 case SCDPUSHWAIT: FFScript::setComboData_push_wait(); break;
34402 case SCDPUSHED: FFScript::setComboData_pushed(); break;
34403 case SCDRAFT: FFScript::setComboData_raft(); break;
34404 case SCDRESETROOM: FFScript::setComboData_reset_room(); break;
34405 case SCDSAVEPOINT: FFScript::setComboData_save_point_type(); break;
34406 case SCDSCREENFREEZE: FFScript::setComboData_screen_freeze_type(); break;
34407 case SCDSECRETCOMBO: FFScript::setComboData_secret_combo(); break;
34408 case SCDSINGULAR: FFScript::setComboData_singular(); break;
34409 case SCDSLOWMOVE: FFScript::setComboData_slow_movement(); break;
34410 case SCDSTATUE: FFScript::setComboData_statue_type(); break;
34411 case SCDSTEPTYPE: FFScript::setComboData_step_type(); break;
34412 case SCDSTEPCHANGETO: FFScript::setComboData_step_change_to(); break;
34413 case SCDSTRIKEREMNANTS: FFScript::setComboData_strike_remnants(); break;
34414 case SCDSTRIKEREMNANTSTYPE: FFScript::setComboData_strike_remnants_type(); break;
34415 case SCDSTRIKECHANGE: FFScript::setComboData_strike_change(); break;
34416 case SCDSTRIKECHANGEITEM: FFScript::setComboData_strike_item(); break;
34417 case SCDTOUCHITEM: FFScript::setComboData_touch_item(); break;
34418 case SCDTOUCHSTAIRS: FFScript::setComboData_touch_stairs(); break;
34419 case SCDTRIGGERTYPE: FFScript::setComboData_trigger_type(); break;
34420 case SCDTRIGGERSENS: FFScript::setComboData_trigger_sensitive(); break;
34421 case SCDWARPTYPE: FFScript::setComboData_warp_type(); break;
34422 case SCDWARPSENS: FFScript::setComboData_warp_sensitive(); break;
34423 case SCDWARPDIRECT: FFScript::setComboData_warp_direct(); break;
34424 case SCDWARPLOCATION: FFScript::setComboData_warp_location(); break;
34425 case SCDWATER: FFScript::setComboData_water(); break;
34426 case SCDWHISTLE: FFScript::setComboData_whistle(); break;
34427 case SCDWINGAME: FFScript::setComboData_win_game(); break;
34428 case SCDBLOCKWEAPLVL: FFScript::setComboData_block_weapon_lvl(); break;
34429 case SCDTILE: FFScript::setComboData_tile(); break;
34430 case SCDFLIP: FFScript::setComboData_flip(); break;
34431 case SCDWALK: FFScript::setComboData_walk(); break;
34432 case SCDTYPE: FFScript::setComboData_type(); break;
34433 case SCDCSETS: FFScript::setComboData_csets(); break;
34434 case SCDFOO: break;
34435 case SCDFRAMES: FFScript::setComboData_frames(); break;
34436 case SCDSPEED: FFScript::setComboData_speed(); break;
34437 case SCDNEXTCOMBO: FFScript::setComboData_nextcombo(); break;
34438 case SCDNEXTCSET: FFScript::setComboData_nextcset(); break;
34439 case SCDFLAG: FFScript::setComboData_flag(); break;
34440 case SCDSKIPANIM: FFScript::setComboData_skipanim(); break;
34441 case SCDNEXTTIMER: FFScript::setComboData_nexttimer(); break;
34442 case SCDSKIPANIMY: FFScript::setComboData_skipanimy(); break;
34443 case SCDANIMFLAGS: FFScript::setComboData_animflags(); break;
34444 case SCDBLOCKWEAPON: FFScript::setComboData_block_weapon(ri->d[rEXP1]); break;
34445 case SCDEXPANSION: FFScript::setComboData_expansion(ri->d[rEXP1]); break;
34446 case SCDSTRIKEWEAPONS: FFScript::setComboData_strike_weapons(ri->d[rEXP1]); break;
34447
34448 //SpriteData
34449
34450 //case GETSPRITEDATASTRING:
34451 case GETSPRITEDATATILE: FFScript::getSpriteDataTile(); break;
34452 case GETSPRITEDATAMISC: FFScript::getSpriteDataCSets(); break;
34453 case GETSPRITEDATACGETS: FFScript::getSpriteDataCSets(); break;
34454 case GETSPRITEDATAFRAMES: FFScript::getSpriteDataFrames(); break;
34455 case GETSPRITEDATASPEED: FFScript::getSpriteDataSpeed(); break;
34456 case GETSPRITEDATATYPE: FFScript::getSpriteDataType(); break;
34457
34458 //case SETSPRITEDATASTRING:
34459 case SETSPRITEDATATILE: FFScript::setSpriteDataTile(); break;
34460 case SETSPRITEDATAMISC: FFScript::setSpriteDataMisc(); break;
34461 case SETSPRITEDATACSETS: FFScript::setSpriteDataCSets(); break;
34462 case SETSPRITEDATAFRAMES: FFScript::setSpriteDataFrames(); break;
34463 case SETSPRITEDATASPEED: FFScript::setSpriteDataSpeed(); break;
34464 case SETSPRITEDATATYPE: FFScript::setSpriteDataType(); break;
34465
34466 //Game over Screen
34467 case SETCONTINUESCREEN: FFScript::FFChangeSubscreenText(); break;
34468 case SETCONTINUESTRING: FFScript::FFSetSaveScreenSetting(); break;
34469
34470 //new npc functions for npc scripts
34471
34472 case NPCDEAD:
34473 FFCore.do_isdeadnpc();
34474 break;
34475
34476 case NPCCANSLIDE:
34477 FFCore.do_canslidenpc();
34478 break;
34479
34480 case NPCSLIDE:
34481 FFCore.do_slidenpc();
34482 break;
34483
34484 case NPCKICKBUCKET:
34485 {
34486 FFScript::deallocateAllArrays(ScriptType::NPC, ri->guyref);
34487 if(type == ScriptType::NPC && ri->guyref == i)
34488 {
34489 FFCore.do_npc_delete();
34490 return RUNSCRIPT_SELFDELETE;
34491 }
34492 FFCore.do_npc_delete();
34493 break;
34494 }
34495 case LWPNDEL:
34496 {
34497 2 FFScript::deallocateAllArrays(ScriptType::Lwpn, ri->lwpn);
34498
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(type == ScriptType::Lwpn && ri->lwpn == i)
34499 {
34500 2 FFCore.do_lweapon_delete();
34501 2 return RUNSCRIPT_SELFDELETE;
34502 }
34503 FFCore.do_lweapon_delete();
34504 break;
34505 }
34506 case EWPNDEL:
34507 {
34508 FFScript::deallocateAllArrays(ScriptType::Ewpn, ri->ewpn);
34509 if(type == ScriptType::Ewpn && ri->ewpn == i)
34510 {
34511 FFCore.do_eweapon_delete();
34512 return RUNSCRIPT_SELFDELETE;
34513 }
34514 FFCore.do_eweapon_delete();
34515 break;
34516 }
34517 case ITEMDEL:
34518 {
34519 8 FFScript::deallocateAllArrays(ScriptType::ItemSprite, ri->itemref);
34520
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(type == ScriptType::ItemSprite && ri->itemref == i)
34521 {
34522
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(FFCore.do_itemsprite_delete())
34523 8 return RUNSCRIPT_SELFDELETE;
34524 }
34525 else FFCore.do_itemsprite_delete();
34526 break;
34527 }
34528
34529 case NPCSTOPBGSFX:
34530 FFCore.do_npc_stopbgsfx();
34531 break;
34532
34533 case NPCATTACK:
34534 FFCore.do_npcattack();
34535 break;
34536
34537 case NPCNEWDIR:
34538 FFCore.do_npc_newdir();
34539 break;
34540
34541 case NPCCONSTWALK:
34542 FFCore.do_npc_constwalk();
34543 break;
34544
34545
34546
34547 case NPCVARWALK:
34548 FFCore.do_npc_varwalk();
34549 break;
34550
34551 case NPCVARWALK8:
34552 FFCore.do_npc_varwalk8();
34553 break;
34554
34555 case NPCCONSTWALK8:
34556 FFCore.do_npc_constwalk8();
34557 break;
34558
34559 case NPCHALTWALK:
34560 FFCore.do_npc_haltwalk();
34561 break;
34562
34563 case NPCHALTWALK8:
34564 FFCore.do_npc_haltwalk8();
34565 break;
34566
34567 case NPCFLOATWALK:
34568 FFCore.do_npc_floatwalk();
34569 break;
34570
34571 case NPCFIREBREATH:
34572 FFCore.do_npc_breathefire();
34573 break;
34574
34575 case NPCNEWDIR8:
34576 FFCore.do_npc_newdir8();
34577 break;
34578
34579 case NPCLINKINRANGE:
34580 FFCore.do_npc_hero_in_range(false);
34581 break;
34582
34583 case NPCCANMOVE:
34584 FFCore.do_npc_canmove(false);
34585 break;
34586
34587 case NPCHITWITH:
34588 FFCore.do_npc_simulate_hit(false);
34589 break;
34590
34591 case NPCKNOCKBACK:
34592 FFCore.do_npc_knockback(false);
34593 break;
34594
34595 case NPCGETINITDLABEL:
34596 FFCore.get_npcdata_initd_label(false);
34597 break;
34598
34599 case NPCADD:
34600 FFCore.do_npc_add(false);
34601 break;
34602
34603 case NPCMOVEPAUSED:
34604 {
34605 ri->d[rEXP1] = 0;
34606 if(GuyH::loadNPC(ri->guyref, "npc->MovePaused()") == SH::_NoError)
34607 {
34608 ri->d[rEXP1] = GuyH::getNPC()->is_move_paused() ? 10000 : 0;
34609 }
34610 break;
34611 }
34612 case NPCMOVE:
34613 {
34614 int32_t dir = ri->d[rINDEX] / 10000;
34615 zfix px = zslongToFix(ri->d[rEXP2]);
34616 int32_t special = ri->d[rEXP1] / 10000;
34617 ri->d[rEXP1] = 0;
34618 if(GuyH::loadNPC(ri->guyref, "npc->Move()") == SH::_NoError)
34619 {
34620 ri->d[rEXP1] = GuyH::getNPC()->moveDir(dir, px, special) ? 10000 : 0;
34621 }
34622 break;
34623 }
34624 case NPCMOVEANGLE:
34625 {
34626 zfix degrees = zslongToFix(ri->d[rINDEX]);
34627 zfix px = zslongToFix(ri->d[rEXP2]);
34628 int32_t special = ri->d[rEXP1] / 10000;
34629 ri->d[rEXP1] = 0;
34630 if(GuyH::loadNPC(ri->guyref, "npc->MoveAtAngle()") == SH::_NoError)
34631 {
34632 ri->d[rEXP1] = GuyH::getNPC()->moveAtAngle(degrees, px, special) ? 10000 : 0;
34633 }
34634 break;
34635 }
34636 case NPCMOVEXY:
34637 {
34638 zfix dx = zslongToFix(ri->d[rINDEX]);
34639 zfix dy = zslongToFix(ri->d[rEXP2]);
34640 int32_t special = ri->d[rEXP1] / 10000;
34641 ri->d[rEXP1] = 0;
34642 if(GuyH::loadNPC(ri->guyref, "npc->MoveXY()") == SH::_NoError)
34643 {
34644 ri->d[rEXP1] = GuyH::getNPC()->movexy(dx, dy, special) ? 10000 : 00;
34645 }
34646 break;
34647 }
34648 case NPCCANMOVEDIR:
34649 {
34650 int32_t dir = ri->d[rINDEX] / 10000;
34651 zfix px = zslongToFix(ri->d[rEXP2]);
34652 int32_t special = ri->d[rEXP1] / 10000;
34653 ri->d[rEXP1] = 0;
34654 if(GuyH::loadNPC(ri->guyref, "npc->CanMove()") == SH::_NoError)
34655 {
34656 ri->d[rEXP1] = GuyH::getNPC()->can_moveDir(dir, px, special) ? 10000 : 0;
34657 }
34658 break;
34659 }
34660 case NPCCANMOVEANGLE:
34661 {
34662 zfix degrees = zslongToFix(ri->d[rINDEX]);
34663 zfix px = zslongToFix(ri->d[rEXP2]);
34664 int32_t special = ri->d[rEXP1] / 10000;
34665 ri->d[rEXP1] = 0;
34666 if(GuyH::loadNPC(ri->guyref, "npc->CanMoveAtAngle()") == SH::_NoError)
34667 {
34668 ri->d[rEXP1] = GuyH::getNPC()->can_moveAtAngle(degrees, px, special) ? 10000 : 0;
34669 }
34670 break;
34671 }
34672 case NPCCANMOVEXY:
34673 {
34674 zfix dx = zslongToFix(ri->d[rINDEX]);
34675 zfix dy = zslongToFix(ri->d[rEXP2]);
34676 int32_t special = ri->d[rEXP1] / 10000;
34677 ri->d[rEXP1] = 0;
34678 if(GuyH::loadNPC(ri->guyref, "npc->CanMoveXY()") == SH::_NoError)
34679 {
34680 ri->d[rEXP1] = GuyH::getNPC()->can_movexy(dx, dy, special) ? 10000 : 0;
34681 }
34682 break;
34683 }
34684 case NPCCANPLACE:
34685 {
34686 ri->guyref = SH::read_stack(ri->sp + 6);
34687 ri->d[rEXP1] = 0;
34688 if(GuyH::loadNPC(ri->guyref, "npc->CanPlace()") == SH::_NoError)
34689 {
34690 zfix nx = zslongToFix(SH::read_stack(ri->sp + 5));
34691 zfix ny = zslongToFix(SH::read_stack(ri->sp + 4));
34692 int special = SH::read_stack(ri->sp + 3) / 10000;
34693 bool kb = SH::read_stack(ri->sp + 2)!=0;
34694 int nw = SH::read_stack(ri->sp + 1) / 10000;
34695 int nh = SH::read_stack(ri->sp + 0) / 10000;
34696 ri->d[rEXP1] = GuyH::getNPC()->scr_canplace(nx, ny, special, kb, nw, nh) ? 10000 : 0;
34697 }
34698 break;
34699 }
34700
34701 case PLAYENHMUSICEX:
34702 // DEPRECATED
34703 do_enh_music(false);
34704 break;
34705
34706 case GETENHMUSICPOS:
34707 FFCore.do_get_music_position();
34708 break;
34709
34710 case SETENHMUSICPOS:
34711 FFCore.do_set_music_position(false);
34712 break;
34713
34714 case SETENHMUSICSPEED:
34715 FFCore.do_set_music_speed(false);
34716 break;
34717
34718 case GETENHMUSICLEN:
34719 FFCore.do_get_music_length();
34720 break;
34721
34722 case SETENHMUSICLOOP:
34723 FFCore.do_set_music_loop();
34724 break;
34725
34726 case ENHCROSSFADE:
34727 do_enh_music_crossfade();
34728 break;
34729
34730 case DIREXISTS:
34731 FFCore.do_checkdir(true);
34732 break;
34733
34734 case FILEEXISTS:
34735 FFCore.do_checkdir(false);
34736 break;
34737
34738 case FILESYSREMOVE:
34739 FFCore.do_fs_remove();
34740 break;
34741
34742 case TOBYTE:
34743 do_tobyte();
34744 break;
34745 case TOWORD:
34746 do_toword();
34747 break;
34748 case TOSHORT: do_toshort(); break;
34749 case TOSIGNEDBYTE: do_tosignedbyte(); break;
34750 case TOINTEGER: do_tointeger(); break;
34751 case CEILING: do_ceiling(); break;
34752 case FLOOR: do_floor(); break;
34753
34754 case FILECLOSE:
34755 {
34756 FFCore.do_fclose();
34757 break;
34758 }
34759 case FILEFREE:
34760 {
34761 1 FFCore.do_deallocate_file();
34762 1 break;
34763 }
34764 case FILEOWN:
34765 {
34766 1 user_file* f = checkFile(ri->fileref, "Free()", false);
34767
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(f) f->own(type, i);
34768 1 break;
34769 }
34770 case FILEISALLOCATED:
34771 {
34772 FFCore.do_file_isallocated();
34773 break;
34774 }
34775 case FILEISVALID:
34776 {
34777 FFCore.do_file_isvalid();
34778 break;
34779 }
34780 case FILEALLOCATE:
34781 {
34782 FFCore.do_allocate_file();
34783 break;
34784 }
34785 case FILEFLUSH:
34786 {
34787 1 FFCore.do_fflush();
34788 1 break;
34789 }
34790 case FILEREMOVE:
34791 {
34792 FFCore.do_fremove();
34793 break;
34794 }
34795 case FILEGETCHAR:
34796 {
34797 FFCore.do_file_getchar();
34798 break;
34799 }
34800 case FILEREWIND:
34801 {
34802 FFCore.do_file_rewind();
34803 break;
34804 }
34805 case FILECLEARERR:
34806 {
34807 FFCore.do_file_clearerr();
34808 break;
34809 }
34810
34811 case FILEOPEN:
34812 {
34813 1 FFCore.do_fopen(false, "rb+");
34814 1 break;
34815 }
34816 case FILECREATE:
34817 {
34818 1 FFCore.do_fopen(false, "wb+");
34819 1 break;
34820 }
34821 case FILEOPENMODE:
34822 {
34823 int32_t arrayptr = get_register(sarg2) / 10000;
34824 string mode;
34825 ArrayH::getString(arrayptr, mode, 16);
34826 FFCore.do_fopen(false, mode.c_str());
34827 break;
34828 }
34829 case FILEREADSTR:
34830 {
34831 FFCore.do_file_readstring();
34832 break;
34833 }
34834 case FILEWRITESTR:
34835 {
34836 279 FFCore.do_file_writestring();
34837 279 break;
34838 }
34839 case FILEPUTCHAR:
34840 {
34841 FFCore.do_file_putchar();
34842 break;
34843 }
34844 case FILEUNGETCHAR:
34845 {
34846 FFCore.do_file_ungetchar();
34847 break;
34848 }
34849
34850 case FILEREADCHARS:
34851 {
34852 FFCore.do_file_readchars();
34853 break;
34854 }
34855 case FILEREADBYTES:
34856 {
34857 FFCore.do_file_readbytes();
34858 break;
34859 }
34860 case FILEREADINTS:
34861 {
34862 FFCore.do_file_readints();
34863 break;
34864 }
34865 case FILEWRITECHARS:
34866 {
34867 FFCore.do_file_writechars();
34868 break;
34869 }
34870 case FILEWRITEBYTES:
34871 {
34872 FFCore.do_file_writebytes();
34873 break;
34874 }
34875 case FILEWRITEINTS:
34876 {
34877 FFCore.do_file_writeints();
34878 break;
34879 }
34880 case FILESEEK:
34881 {
34882 FFCore.do_file_seek();
34883 break;
34884 }
34885 case FILEGETERROR:
34886 {
34887 FFCore.do_file_geterr();
34888 break;
34889 }
34890 //Directory
34891 case DIRECTORYGET:
34892 {
34893 FFCore.do_directory_get();
34894 break;
34895 }
34896 case DIRECTORYRELOAD:
34897 {
34898 FFCore.do_directory_reload();
34899 break;
34900 }
34901 case DIRECTORYFREE:
34902 {
34903 FFCore.do_directory_free();
34904 break;
34905 }
34906 case DIRECTORYOWN:
34907 {
34908 if(user_dir* dr = checkDir(ri->directoryref, "Own()"))
34909 {
34910 dr->own(type, i);
34911 }
34912 break;
34913 }
34914 //Stack
34915 case STACKFREE:
34916 {
34917 if(user_stack* st = checkStack(ri->stackref, "Free()", true))
34918 {
34919 st->clear();
34920 }
34921 break;
34922 }
34923 case STACKOWN:
34924 {
34925 if(user_stack* st = checkStack(ri->stackref, "Own()"))
34926 {
34927 st->own(type, i);
34928 }
34929 break;
34930 }
34931 case STACKCLEAR:
34932 {
34933 if(user_stack* st = checkStack(ri->stackref, "Clear()"))
34934 {
34935 st->clearStack();
34936 }
34937 break;
34938 }
34939 case STACKGET:
34940 {
34941 if(user_stack* st = checkStack(ri->stackref, "Get()", true))
34942 {
34943 int32_t indx = get_register(sarg1); //NOT /10000
34944 set_register(sarg1, st->get(indx)); //NOT *10000
34945 }
34946 else set_register(sarg1, 0L);
34947 break;
34948 }
34949 case STACKSET:
34950 {
34951 if(user_stack* st = checkStack(ri->stackref, "Set()", true))
34952 {
34953 int32_t indx = get_register(sarg1); //NOT /10000
34954 int32_t val = get_register(sarg2); //NOT /10000
34955 st->set(indx, val); //NOT *10000
34956 }
34957 break;
34958 }
34959 case STACKPOPBACK:
34960 {
34961 if(user_stack* st = checkStack(ri->stackref, "PopBack()", true))
34962 {
34963 set_register(sarg1, st->pop_back()); //NOT *10000
34964 }
34965 else set_register(sarg1, 0L);
34966 break;
34967 }
34968 case STACKPOPFRONT:
34969 {
34970 if(user_stack* st = checkStack(ri->stackref, "PopFront()", true))
34971 {
34972 set_register(sarg1, st->pop_front()); //NOT *10000
34973 }
34974 else set_register(sarg1, 0L);
34975 break;
34976 }
34977 case STACKPEEKBACK:
34978 {
34979 if(user_stack* st = checkStack(ri->stackref, "PeekBack()", true))
34980 {
34981 set_register(sarg1, st->peek_back()); //NOT *10000
34982 }
34983 else set_register(sarg1, 0L);
34984 break;
34985 }
34986 case STACKPEEKFRONT:
34987 {
34988 if(user_stack* st = checkStack(ri->stackref, "PeekFront()", true))
34989 {
34990 set_register(sarg1, st->peek_front()); //NOT *10000
34991 }
34992 else set_register(sarg1, 0L);
34993 break;
34994 }
34995 case STACKPUSHBACK:
34996 {
34997 if(user_stack* st = checkStack(ri->stackref, "PushBack()", true))
34998 {
34999 int32_t val = get_register(sarg1); //NOT /10000
35000 st->push_back(val);
35001 }
35002 break;
35003 }
35004 case STACKPUSHFRONT:
35005 {
35006 if(user_stack* st = checkStack(ri->stackref, "PushFront()", true))
35007 {
35008 int32_t val = get_register(sarg1); //NOT /10000
35009 st->push_front(val);
35010 }
35011 break;
35012 }
35013
35014 //Module
35015 case MODULEGETIC:
35016 {
35017
35018 int32_t buf_pointer = SH::get_arg(sarg1, false) / 10000;
35019 int32_t element = SH::get_arg(sarg2, false) / 10000;
35020
35021 if ( ((unsigned)element) > 511 )
35022 {
35023 Z_scripterrlog("Illegal itemclass supplied to ZInfo->GetItemClass().\nLegal values are 1 to 511.\n");
35024 }
35025 else
35026 {
35027 char buffer[256] = {0};
35028 strcpy(buffer,ZI.getItemClassName(element));
35029 buffer[255] = '\0';
35030 if(ArrayH::setArray(buf_pointer, buffer) == SH::_Overflow)
35031 {
35032 Z_scripterrlog("Dest string supplied to 'Module->GetItemClass()' is not large enough\n");
35033 }
35034 }
35035
35036 break;
35037 }
35038
35039 //{ Randgen Stuff
35040 case RNGRAND1:
35041 if(user_rng* r = checkRNG(ri->rngref, "Rand()"))
35042 {
35043 ri->d[rEXP1] = r->rand(214748, -214748)*10000L;
35044 }
35045 else ri->d[rEXP1] = -10000L;
35046 break;
35047 case RNGRAND2:
35048
1/2
✓ Branch 0 taken 1338 times.
✗ Branch 1 not taken.
1338 if(user_rng* r = checkRNG(ri->rngref, "Rand(int32_t)"))
35049 {
35050 1338 set_register(sarg1,r->rand(get_register(sarg1)/10000L)*10000L);
35051 1338 }
35052 else set_register(sarg1,-10000L);
35053 1338 break;
35054 case RNGRAND3:
35055
1/2
✓ Branch 0 taken 301905 times.
✗ Branch 1 not taken.
301905 if(user_rng* r = checkRNG(ri->rngref, "Rand(int32_t,int32_t)"))
35056 {
35057 301905 set_register(sarg1,r->rand(get_register(sarg1)/10000L, get_register(sarg2)/10000L)* 10000L);
35058 301905 }
35059 else set_register(sarg1,-10000L);
35060 301905 break;
35061 case RNGLRAND1:
35062 if(user_rng* r = checkRNG(ri->rngref, "LRand()"))
35063 {
35064 ri->d[rEXP1] = r->rand();
35065 }
35066 else ri->d[rEXP1] = -10000L;
35067 break;
35068 case RNGLRAND2:
35069 if(user_rng* r = checkRNG(ri->rngref, "LRand(int32_t)"))
35070 {
35071 ri->d[rEXP1] = r->rand(get_register(sarg1));
35072 }
35073 else ri->d[rEXP1] = -10000L;
35074 break;
35075 case RNGLRAND3:
35076 if(user_rng* r = checkRNG(ri->rngref, "LRand(int32_t,int32_t)"))
35077 {
35078 ri->d[rEXP1] = r->rand(get_register(sarg1), get_register(sarg2));
35079 }
35080 else ri->d[rEXP1] = -10000L;
35081 break;
35082 case RNGSEED:
35083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
73 if(user_rng* r = checkRNG(ri->rngref, "SRand(int32_t)"))
35084 {
35085 73 r->srand(get_register(sarg1));
35086 73 }
35087 73 break;
35088 case RNGRSEED:
35089 if(user_rng* r = checkRNG(ri->rngref, "SRand()"))
35090 {
35091 ri->d[rEXP1] = r->srand();
35092 }
35093 else ri->d[rEXP1] = -10000;
35094 break;
35095 case RNGFREE:
35096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(user_rng* r = checkRNG(ri->rngref, "Free()", true))
35097 {
35098 6 r->clear();
35099 6 }
35100 6 break;
35101 case RNGOWN:
35102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(user_rng* r = checkRNG(ri->rngref, "Own()", false))
35103 {
35104 8 r->own(type, i);
35105 8 }
35106 8 break;
35107 //}
35108 case LOADGENERICDATA:
35109 68 FFCore.do_loadgenericdata(false); break;
35110 case RUNGENFRZSCR:
35111 {
35112 10 bool r = FFCore.runGenericFrozenEngine(word(ri->genericdataref));
35113 10 set_register(sarg1, r ? 10000L : 0L);
35114 10 break;
35115 }
35116
35117 default:
35118 {
35119 Z_scripterrlog("Invalid ZASM command %lu reached; terminating\n", scommand);
35120 hit_invalid_zasm = true;
35121 scommand = 0xFFFF;
35122 break;
35123 }
35124 }
35125
1/2
✓ Branch 0 taken 708162204 times.
✗ Branch 1 not taken.
708162204 if(earlyretval == RUNSCRIPT_SELFDELETE)
35126 {
35127 earlyretval = -1;
35128 return RUNSCRIPT_SELFDELETE;
35129 }
35130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708162204 times.
708162204 if(hit_invalid_zasm) break;
35131
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 708162204 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
708162204 if(script_funcrun && ri->pc == MAX_PC)
35132 return RUNSCRIPT_OK;
35133
35134 #ifdef _SCRIPT_COUNTER
35135 end_time = std::chrono::steady_clock::now();
35136 script_timer[scommand] += std::chrono::duration_cast<std::chrono::nanoseconds>(end_time - start_time).count();
35137 script_execount[scommand] += 1;
35138 #endif
35139
35140
2/2
✓ Branch 0 taken 708100241 times.
✓ Branch 1 taken 61963 times.
708162204 if (type == ScriptType::Combo)
35141 {
35142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61963 times.
61963 if(combopos_modified == i)
35143 {
35144 //Combo changed! Abort script!
35145 return RUNSCRIPT_OK;
35146 }
35147 61963 }
35148
1/2
✓ Branch 0 taken 708162204 times.
✗ Branch 1 not taken.
708162204 if(increment) ri->pc++;
35149 else increment = true;
35150
1/2
✓ Branch 0 taken 708162204 times.
✗ Branch 1 not taken.
708162204 if ( ri->pc == MAX_PC ) //rolled over from overflow?
35151 {
35152 Z_scripterrlog("Script PC overflow! Too many ZASM lines?\n");
35153 ri->pc = 0;
35154 scommand = 0xFFFF;
35155 }
35156
35157
1/2
✓ Branch 0 taken 708162204 times.
✗ Branch 1 not taken.
708162204 if(earlyretval > -1) //Should this be below the 'commands_run += 1'? Unsure. -Em
35158 {
35159 auto v = earlyretval;
35160 earlyretval = -1;
35161 return earlyretval;
35162 }
35163
35164 // If running a JIT compiled script, we're only here to do a few commands.
35165 708162204 commands_run += 1;
35166
3/4
✓ Branch 0 taken 708162204 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3089598 times.
✓ Branch 3 taken 705072606 times.
708162204 if (is_jitted && commands_run == jitted_uncompiled_command_count) break;
35167 }
35168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714666587 times.
714666587 if(script_funcrun) return RUNSCRIPT_OK;
35169
35170
2/2
✓ Branch 0 taken 714666576 times.
✓ Branch 1 taken 11 times.
714666587 if(!scriptCanSave)
35171 11 scriptCanSave=true;
35172
35173
2/2
✓ Branch 0 taken 712802503 times.
✓ Branch 1 taken 1864084 times.
714666587 if(scommand == WAITDRAW)
35174 {
35175
3/9
✓ Branch 0 taken 1851416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 188 times.
✓ Branch 6 taken 12480 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
1864084 switch(type)
35176 {
35177 case ScriptType::Global:
35178 case ScriptType::Player:
35179 case ScriptType::DMap:
35180 case ScriptType::OnMap:
35181 case ScriptType::PassiveSubscreen:
35182 case ScriptType::ActiveSubscreen:
35183 case ScriptType::Screen:
35184 case ScriptType::Combo:
35185 1851416 FFCore.waitdraw(type, i) = true;
35186 1851416 break;
35187
35188 case ScriptType::Item:
35189 {
35190 if (!get_qr(qr_NOITEMWAITDRAW))
35191 {
35192 FFCore.waitdraw(ScriptType::Item, i) = true;
35193 }
35194 break;
35195 }
35196
35197 case ScriptType::NPC:
35198 {
35199 //enemy *wp = (enemy*)guys.spr(i);
35200 //wp->waitdraw = 1;
35201 guys.spr(GuyH::getNPCIndex(i))->waitdraw = 1;
35202 break;
35203 }
35204 case ScriptType::Lwpn:
35205 {
35206 188 Lwpns.spr(LwpnH::getLWeaponIndex(i))->waitdraw = 1;
35207 188 break;
35208 }
35209
35210 case ScriptType::Ewpn:
35211 {
35212 12480 Ewpns.spr(EwpnH::getEWeaponIndex(i))->waitdraw = 1;
35213 12480 break;
35214 }
35215 case ScriptType::ItemSprite:
35216 {
35217 items.spr(ItemH::getItemIndex(i))->waitdraw = 1;
35218 break;
35219 }
35220
35221 case ScriptType::FFC:
35222 {
35223 if ( !(get_qr(qr_NOFFCWAITDRAW)) )
35224 {
35225 FFCore.waitdraw(ScriptType::FFC, i) = true;
35226 }
35227 else
35228 {
35229 Z_scripterrlog("Waitdraw cannot be used in script type: %s\n", "ffc, with Script Rule 'No FFC Waitdraw() enabled!");
35230 }
35231 break;
35232 }
35233
35234 case ScriptType::Generic:
35235 case ScriptType::GenericFrozen:
35236 //No Waitdraw
35237 break;
35238
35239 default:
35240 Z_scripterrlog("Waitdraw cannot be used in script type: %s\n", ScriptTypeToString(type));
35241 break;
35242 }
35243 1864084 }
35244
35245
2/2
✓ Branch 0 taken 70473 times.
✓ Branch 1 taken 714596114 times.
714666587 if(scommand == 0xFFFF) //Quit/command list end reached/bad command
35246 {
35247
8/11
✓ Branch 0 taken 1256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6683 times.
✓ Branch 3 taken 18 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
✓ Branch 6 taken 1009 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60621 times.
✓ Branch 9 taken 836 times.
✓ Branch 10 taken 40 times.
70473 switch(type)
35248 {
35249 case ScriptType::FFC:
35250 {
35251 6683 tmpscr->ffcs[i].script = 0;
35252 6683 auto& data = get_script_engine_data(type, i);
35253 6683 data.doscript = false;
35254 }
35255 6683 break;
35256
35257 case ScriptType::Screen:
35258 18 tmpscr->script = 0;
35259 case ScriptType::Global:
35260 case ScriptType::Player:
35261 case ScriptType::DMap:
35262 case ScriptType::OnMap:
35263 case ScriptType::ActiveSubscreen:
35264 case ScriptType::PassiveSubscreen:
35265 case ScriptType::Combo:
35266 {
35267 1274 auto& data = get_script_engine_data(type, i);
35268 1274 data.doscript = false;
35269 }
35270 1274 break;
35271
35272 case ScriptType::Generic:
35273 user_scripts[script].quit();
35274 break;
35275
35276 case ScriptType::GenericFrozen:
35277 10 gen_active_doscript = 0;
35278 10 break;
35279
35280 case ScriptType::Item:
35281 {
35282
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
1009 bool collect = ( ( i < 1 ) || (i == COLLECT_SCRIPT_ITEM_ZERO) );
35283
3/4
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
✓ Branch 2 taken 194 times.
✗ Branch 3 not taken.
1009 int new_i = ( collect ) ? (( i != COLLECT_SCRIPT_ITEM_ZERO ) ? (i * -1) : 0) : i;
35284 1009 auto& data = get_script_engine_data(ScriptType::Item, i);
35285
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
1009 if ( !collect )
35286 {
35287
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 815 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
815 if ( (itemsbuf[i].flags&ITEM_PASSIVESCRIPT) && game->item[i] ) itemsbuf[i].script = 0; //Quit perpetual scripts, too.
35288 815 data.doscript = 0;
35289 815 data.ref.Clear();
35290 815 }
35291 else
35292 {
35293 194 data.doscript = 0;
35294 194 data.ref.Clear();
35295 }
35296 1009 data.initialized = false;
35297 1009 break;
35298 }
35299 case ScriptType::NPC:
35300 {
35301 guys.spr(GuyH::getNPCIndex(i))->doscript = 0;
35302 guys.spr(GuyH::getNPCIndex(i))->weaponscript = 0;
35303 guys.spr(GuyH::getNPCIndex(i))->initialised = 0;
35304 break;
35305 }
35306 case ScriptType::Lwpn:
35307 {
35308 60621 Lwpns.spr(LwpnH::getLWeaponIndex(i))->doscript = 0;
35309 60621 Lwpns.spr(LwpnH::getLWeaponIndex(i))->weaponscript = 0;
35310 60621 Lwpns.spr(LwpnH::getLWeaponIndex(i))->initialised = 0;
35311 60621 break;
35312 }
35313 case ScriptType::Ewpn:
35314 {
35315
35316 836 Ewpns.spr(EwpnH::getEWeaponIndex(i))->doscript = 0;
35317 836 Ewpns.spr(EwpnH::getEWeaponIndex(i))->weaponscript = 0;
35318 836 Ewpns.spr(EwpnH::getEWeaponIndex(i))->initialised = 0;
35319 836 break;
35320 }
35321 case ScriptType::ItemSprite:
35322 {
35323 40 items.spr(ItemH::getItemIndex(i))->doscript = 0;
35324 40 items.spr(ItemH::getItemIndex(i))->script = 0;
35325 40 items.spr(ItemH::getItemIndex(i))->initialised = 0;
35326 40 break;
35327 }
35328 }
35329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70473 times.
70473 if(!no_dealloc)
35330
3/3
✓ Branch 0 taken 69446 times.
✓ Branch 1 taken 1009 times.
✓ Branch 2 taken 18 times.
70473 switch(type)
35331 {
35332 case ScriptType::Item:
35333 {
35334
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
1009 bool collect = ( ( i < 1 ) || (i == COLLECT_SCRIPT_ITEM_ZERO) );
35335
3/4
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
✓ Branch 2 taken 194 times.
✗ Branch 3 not taken.
1009 int new_i = ( collect ) ? (( i != COLLECT_SCRIPT_ITEM_ZERO ) ? (i * -1) : 0) : i;
35336 1009 FFScript::deallocateAllArrays(ScriptType::Item, new_i);
35337 1009 break;
35338 }
35339
35340 case ScriptType::Screen:
35341 {
35342 18 FFScript::deallocateAllArrays(ScriptType::Screen, 0);
35343 18 break;
35344 }
35345
35346 default:
35347 69446 FFScript::deallocateAllArrays(type, i);
35348 69446 break;
35349 70473 }
35350
35351 70473 return RUNSCRIPT_STOPPED;
35352 }
35353 else
35354 714596114 ri->pc++;
35355
35356 714596114 return RUNSCRIPT_OK;
35357 714666597 }
35358
35359 script_data* load_scrdata(ScriptType type, word script, int32_t i)
35360 {
35361 switch(type)
35362 {
35363 case ScriptType::FFC:
35364 return ffscripts[script];
35365 case ScriptType::NPC:
35366 return guyscripts[guys.spr(GuyH::getNPCIndex(i))->script];
35367 case ScriptType::Lwpn:
35368 return lwpnscripts[Lwpns.spr(LwpnH::getLWeaponIndex(i))->weaponscript];
35369 case ScriptType::Ewpn:
35370 return ewpnscripts[Ewpns.spr(EwpnH::getEWeaponIndex(i))->weaponscript];
35371 case ScriptType::ItemSprite:
35372 return itemspritescripts[items.spr(ItemH::getItemIndex(i))->script];
35373 case ScriptType::Item:
35374 return itemscripts[script];
35375 case ScriptType::Global:
35376 return globalscripts[script];
35377 case ScriptType::Generic:
35378 case ScriptType::GenericFrozen:
35379 return genericscripts[script];
35380 case ScriptType::Player:
35381 return playerscripts[script];
35382 case ScriptType::DMap:
35383 return dmapscripts[script];
35384 case ScriptType::OnMap:
35385 case ScriptType::ActiveSubscreen:
35386 case ScriptType::PassiveSubscreen:
35387 return dmapscripts[script];
35388 case ScriptType::Screen:
35389 return screenscripts[script];
35390 case ScriptType::Combo:
35391 return comboscripts[script];
35392 }
35393 return nullptr;
35394 }
35395
35396 //This keeps ffc scripts running beyond the first frame.
35397 7298313 int32_t ffscript_engine(const bool preload)
35398 {
35399
2/2
✓ Branch 0 taken 7282772 times.
✓ Branch 1 taken 15541 times.
7298313 if(preload)
35400 {
35401 15541 throwGenScriptEvent(GENSCR_EVENT_FFC_PRELOAD);
35402 15541 }
35403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7298313 times.
7298313 if (!FFCore.system_suspend[susptFFCSCRIPTS])
35404 {
35405 //run screen script, first
35406 //zprint("Screen Script Preload? %s \n", ( tmpscr->preloadscript ? "true" : "false"));
35407
4/4
✓ Branch 0 taken 15541 times.
✓ Branch 1 taken 7282772 times.
✓ Branch 2 taken 15528 times.
✓ Branch 3 taken 7267244 times.
7298313 if(( preload && tmpscr->preloadscript) || !preload )
35408 {
35409
2/2
✓ Branch 0 taken 6969052 times.
✓ Branch 1 taken 313733 times.
7282785 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
35410 {
35411
3/4
✓ Branch 0 taken 9269 times.
✓ Branch 1 taken 304464 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9269 times.
313733 if ( tmpscr->script > 0 && FFCore.doscript(ScriptType::Screen) )
35412 {
35413 9269 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script);
35414 9269 }
35415 313733 }
35416 7282785 }
35417 7298313 word c = tmpscr->numFFC();
35418
2/2
✓ Branch 0 taken 229217205 times.
✓ Branch 1 taken 7298313 times.
236515518 for(word i = 0; i < c; i++)
35419 {
35420
2/2
✓ Branch 0 taken 4717155 times.
✓ Branch 1 taken 224500050 times.
229217205 if(tmpscr->ffcs[i].script == 0)
35421 224500050 continue;
35422
35423
4/4
✓ Branch 0 taken 6100 times.
✓ Branch 1 taken 4711055 times.
✓ Branch 2 taken 1703 times.
✓ Branch 3 taken 4397 times.
4717155 if(preload && !(tmpscr->ffcs[i].flags&ffPRELOAD))
35424 4397 continue;
35425
35426
4/4
✓ Branch 0 taken 4708199 times.
✓ Branch 1 taken 4559 times.
✓ Branch 2 taken 4676899 times.
✓ Branch 3 taken 31300 times.
4712758 if((tmpscr->ffcs[i].flags&ffIGNOREHOLDUP)==0 && Hero.getHoldClk()>0)
35427 31300 continue;
35428
35429 4681458 ZScriptVersion::RunScript(ScriptType::FFC, tmpscr->ffcs[i].script, i);
35430 4681458 }
35431 7298313 }
35432
35433
35434 7298313 return 0;
35435 }
35436
35437
35438
35439 ///----------------------------------------------------------------------------------------------------
35440
35441 226 void FFScript::user_files_init()
35442 {
35443
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 226 times.
58082 for(int32_t q = 0; q < MAX_USER_FILES; ++q)
35444 {
35445 57856 script_files[q].clear();
35446 57856 }
35447 226 }
35448
35449 226 void FFScript::user_dirs_init()
35450 {
35451
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 226 times.
58082 for(int32_t q = 0; q < MAX_USER_DIRS; ++q)
35452 {
35453 57856 script_dirs[q].clear();
35454 57856 }
35455 226 }
35456 347 void FFScript::user_objects_init()
35457 {
35458
2/2
✓ Branch 0 taken 74517556 times.
✓ Branch 1 taken 347 times.
74517903 for(int32_t q = 0; q < MAX_USER_OBJECTS; ++q)
35459 {
35460 74517556 script_objects[q].clear(false);
35461 74517556 }
35462 347 max_valid_object = 0;
35463 347 }
35464
35465 226 void FFScript::user_stacks_init()
35466 {
35467
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 226 times.
58082 for(int32_t q = 0; q < MAX_USER_STACKS; ++q)
35468 {
35469 57856 script_stacks[q].clear();
35470 57856 }
35471 226 }
35472
35473 408 void FFScript::user_rng_init()
35474 {
35475
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 408 times.
104856 for(int32_t q = 0; q < MAX_USER_RNGS; ++q)
35476 {
35477 104448 replay_register_rng(&script_rnggens[q]);
35478 104448 script_rngs[q].clear();
35479 104448 script_rngs[q].set_gen(&script_rnggens[q]);
35480 104448 }
35481 408 }
35482
35483 void FFScript::user_paldata_init()
35484 {
35485 for (int32_t q = 0; q < MAX_USER_STACKS; ++q)
35486 {
35487 script_paldatas[q].clear();
35488 }
35489 }
35490
35491 2 int32_t FFScript::get_free_file(bool skipError)
35492 {
35493
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 for(int32_t q = 0; q < MAX_USER_FILES; ++q)
35494 {
35495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!script_files[q].reserved)
35496 {
35497 2 script_files[q].reserved = true;
35498 2 return q+1; //1-indexed; 0 is null value
35499 }
35500 }
35501 if(!skipError) Z_scripterrlog("get_free_file() could not find a valid free file pointer!\n");
35502 return 0;
35503 2 }
35504
35505 int32_t FFScript::get_free_object(bool skipError)
35506 {
35507 for(int32_t q = 0; q < MAX_USER_OBJECTS; ++q)
35508 {
35509 if(!script_objects[q].reserved)
35510 {
35511 script_objects[q].reserved = true;
35512 if(q >= max_valid_object)
35513 max_valid_object = q+1;
35514 return q+1; //1-indexed; 0 is null value
35515 }
35516 }
35517 if(!skipError) Z_scripterrlog("get_free_object() could not find a valid free object pointer!\n");
35518 return 0;
35519 }
35520
35521 int32_t FFScript::get_free_directory(bool skipError)
35522 {
35523 for(int32_t q = 0; q < MAX_USER_DIRS; ++q)
35524 {
35525 if(!script_dirs[q].reserved)
35526 {
35527 script_dirs[q].reserved = true;
35528 return q+1; //1-indexed; 0 is null value
35529 }
35530 }
35531 if(!skipError) Z_scripterrlog("get_free_directory() could not find a valid free directory pointer!\n");
35532 return 0;
35533 }
35534
35535 22 int32_t FFScript::get_free_rng(bool skipError)
35536 {
35537
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 for(int32_t q = 0; q < MAX_USER_RNGS; ++q)
35538 {
35539
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 22 times.
31 if(!script_rngs[q].reserved)
35540 {
35541 22 script_rngs[q].reserved = true;
35542 22 return q+1; //1-indexed; 0 is null value
35543 }
35544 9 }
35545 if(!skipError) Z_scripterrlog("get_free_rng() could not find a valid free rng pointer!\n");
35546 return 0;
35547 22 }
35548
35549 int32_t FFScript::get_free_paldata(bool skipError)
35550 {
35551 for (int32_t q = 0; q < MAX_USER_PALDATAS; ++q)
35552 {
35553 if (!script_paldatas[q].reserved)
35554 {
35555 script_paldatas[q].reserved = true;
35556 return q+1; //1-indexed; 0 is null value
35557 }
35558 }
35559 if (!skipError) Z_scripterrlog("get_free_paldata() could not find a valid free paldata pointer!\n");
35560 return 0;
35561 }
35562
35563 int32_t FFScript::get_free_stack(bool skipError)
35564 {
35565 for(int32_t q = 0; q < MAX_USER_STACKS; ++q)
35566 {
35567 if(!script_stacks[q].reserved)
35568 {
35569 script_stacks[q].reserved = true;
35570 return q+1; //1-indexed; 0 is null value
35571 }
35572 }
35573 if(!skipError) Z_scripterrlog("get_free_stack() could not find a valid free stack pointer!\n");
35574 return 0;
35575 }
35576
35577 // Gotten from 'https://fileinfo.com/filetypes/executable'
35578
187/376
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 116 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 116 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 116 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 116 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 116 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 116 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 116 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 116 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 116 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 116 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 116 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 116 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 116 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 116 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 116 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 116 times.
✗ Branch 37 not taken.
✓ Branch 38 taken 116 times.
✗ Branch 39 not taken.
✓ Branch 40 taken 116 times.
✗ Branch 41 not taken.
✓ Branch 42 taken 116 times.
✗ Branch 43 not taken.
✓ Branch 44 taken 116 times.
✗ Branch 45 not taken.
✓ Branch 46 taken 116 times.
✗ Branch 47 not taken.
✓ Branch 48 taken 116 times.
✗ Branch 49 not taken.
✓ Branch 50 taken 116 times.
✗ Branch 51 not taken.
✓ Branch 52 taken 116 times.
✗ Branch 53 not taken.
✓ Branch 54 taken 116 times.
✗ Branch 55 not taken.
✓ Branch 56 taken 116 times.
✗ Branch 57 not taken.
✓ Branch 58 taken 116 times.
✗ Branch 59 not taken.
✓ Branch 60 taken 116 times.
✗ Branch 61 not taken.
✓ Branch 62 taken 116 times.
✗ Branch 63 not taken.
✓ Branch 64 taken 116 times.
✗ Branch 65 not taken.
✓ Branch 66 taken 116 times.
✗ Branch 67 not taken.
✓ Branch 68 taken 116 times.
✗ Branch 69 not taken.
✓ Branch 70 taken 116 times.
✗ Branch 71 not taken.
✓ Branch 72 taken 116 times.
✗ Branch 73 not taken.
✓ Branch 74 taken 116 times.
✗ Branch 75 not taken.
✓ Branch 76 taken 116 times.
✗ Branch 77 not taken.
✓ Branch 78 taken 116 times.
✗ Branch 79 not taken.
✓ Branch 80 taken 116 times.
✗ Branch 81 not taken.
✓ Branch 82 taken 116 times.
✗ Branch 83 not taken.
✓ Branch 84 taken 116 times.
✗ Branch 85 not taken.
✓ Branch 86 taken 116 times.
✗ Branch 87 not taken.
✓ Branch 88 taken 116 times.
✗ Branch 89 not taken.
✓ Branch 90 taken 116 times.
✗ Branch 91 not taken.
✓ Branch 92 taken 116 times.
✗ Branch 93 not taken.
✓ Branch 94 taken 116 times.
✗ Branch 95 not taken.
✓ Branch 96 taken 116 times.
✗ Branch 97 not taken.
✓ Branch 98 taken 116 times.
✗ Branch 99 not taken.
✓ Branch 100 taken 116 times.
✗ Branch 101 not taken.
✓ Branch 102 taken 116 times.
✗ Branch 103 not taken.
✓ Branch 104 taken 116 times.
✗ Branch 105 not taken.
✓ Branch 106 taken 116 times.
✗ Branch 107 not taken.
✓ Branch 108 taken 116 times.
✗ Branch 109 not taken.
✓ Branch 110 taken 116 times.
✗ Branch 111 not taken.
✓ Branch 112 taken 116 times.
✗ Branch 113 not taken.
✓ Branch 114 taken 116 times.
✗ Branch 115 not taken.
✓ Branch 116 taken 116 times.
✗ Branch 117 not taken.
✓ Branch 118 taken 116 times.
✗ Branch 119 not taken.
✓ Branch 120 taken 116 times.
✗ Branch 121 not taken.
✓ Branch 122 taken 116 times.
✗ Branch 123 not taken.
✓ Branch 124 taken 116 times.
✗ Branch 125 not taken.
✓ Branch 126 taken 116 times.
✗ Branch 127 not taken.
✓ Branch 128 taken 116 times.
✗ Branch 129 not taken.
✓ Branch 130 taken 116 times.
✗ Branch 131 not taken.
✓ Branch 132 taken 116 times.
✗ Branch 133 not taken.
✓ Branch 134 taken 116 times.
✗ Branch 135 not taken.
✓ Branch 136 taken 116 times.
✗ Branch 137 not taken.
✓ Branch 138 taken 116 times.
✗ Branch 139 not taken.
✓ Branch 140 taken 116 times.
✗ Branch 141 not taken.
✓ Branch 142 taken 116 times.
✗ Branch 143 not taken.
✓ Branch 144 taken 116 times.
✗ Branch 145 not taken.
✓ Branch 146 taken 116 times.
✗ Branch 147 not taken.
✓ Branch 148 taken 116 times.
✗ Branch 149 not taken.
✓ Branch 150 taken 116 times.
✗ Branch 151 not taken.
✓ Branch 152 taken 116 times.
✗ Branch 153 not taken.
✓ Branch 154 taken 116 times.
✗ Branch 155 not taken.
✓ Branch 156 taken 116 times.
✗ Branch 157 not taken.
✓ Branch 158 taken 116 times.
✗ Branch 159 not taken.
✓ Branch 160 taken 116 times.
✗ Branch 161 not taken.
✓ Branch 162 taken 116 times.
✗ Branch 163 not taken.
✓ Branch 164 taken 116 times.
✗ Branch 165 not taken.
✓ Branch 166 taken 116 times.
✗ Branch 167 not taken.
✓ Branch 168 taken 116 times.
✗ Branch 169 not taken.
✓ Branch 170 taken 116 times.
✗ Branch 171 not taken.
✓ Branch 172 taken 116 times.
✗ Branch 173 not taken.
✓ Branch 174 taken 116 times.
✗ Branch 175 not taken.
✓ Branch 176 taken 116 times.
✗ Branch 177 not taken.
✓ Branch 178 taken 116 times.
✗ Branch 179 not taken.
✓ Branch 180 taken 116 times.
✗ Branch 181 not taken.
✓ Branch 182 taken 116 times.
✗ Branch 183 not taken.
✓ Branch 184 taken 116 times.
✗ Branch 185 not taken.
✓ Branch 186 taken 116 times.
✗ Branch 187 not taken.
✓ Branch 188 taken 116 times.
✗ Branch 189 not taken.
✓ Branch 190 taken 116 times.
✗ Branch 191 not taken.
✓ Branch 192 taken 116 times.
✗ Branch 193 not taken.
✓ Branch 194 taken 116 times.
✗ Branch 195 not taken.
✓ Branch 196 taken 116 times.
✗ Branch 197 not taken.
✓ Branch 198 taken 116 times.
✗ Branch 199 not taken.
✓ Branch 200 taken 116 times.
✗ Branch 201 not taken.
✓ Branch 202 taken 116 times.
✗ Branch 203 not taken.
✓ Branch 204 taken 116 times.
✗ Branch 205 not taken.
✓ Branch 206 taken 116 times.
✗ Branch 207 not taken.
✓ Branch 208 taken 116 times.
✗ Branch 209 not taken.
✓ Branch 210 taken 116 times.
✗ Branch 211 not taken.
✓ Branch 212 taken 116 times.
✗ Branch 213 not taken.
✓ Branch 214 taken 116 times.
✗ Branch 215 not taken.
✓ Branch 216 taken 116 times.
✗ Branch 217 not taken.
✓ Branch 218 taken 116 times.
✗ Branch 219 not taken.
✓ Branch 220 taken 116 times.
✗ Branch 221 not taken.
✓ Branch 222 taken 116 times.
✗ Branch 223 not taken.
✓ Branch 224 taken 116 times.
✗ Branch 225 not taken.
✓ Branch 226 taken 116 times.
✗ Branch 227 not taken.
✓ Branch 228 taken 116 times.
✗ Branch 229 not taken.
✓ Branch 230 taken 116 times.
✗ Branch 231 not taken.
✓ Branch 232 taken 116 times.
✗ Branch 233 not taken.
✓ Branch 234 taken 116 times.
✗ Branch 235 not taken.
✓ Branch 236 taken 116 times.
✗ Branch 237 not taken.
✓ Branch 238 taken 116 times.
✗ Branch 239 not taken.
✓ Branch 240 taken 116 times.
✗ Branch 241 not taken.
✓ Branch 242 taken 116 times.
✗ Branch 243 not taken.
✓ Branch 244 taken 116 times.
✗ Branch 245 not taken.
✓ Branch 246 taken 116 times.
✗ Branch 247 not taken.
✓ Branch 248 taken 116 times.
✗ Branch 249 not taken.
✓ Branch 250 taken 116 times.
✗ Branch 251 not taken.
✓ Branch 252 taken 116 times.
✗ Branch 253 not taken.
✓ Branch 254 taken 116 times.
✗ Branch 255 not taken.
✓ Branch 256 taken 116 times.
✗ Branch 257 not taken.
✓ Branch 258 taken 116 times.
✗ Branch 259 not taken.
✓ Branch 260 taken 116 times.
✗ Branch 261 not taken.
✓ Branch 262 taken 116 times.
✗ Branch 263 not taken.
✓ Branch 264 taken 116 times.
✗ Branch 265 not taken.
✓ Branch 266 taken 116 times.
✗ Branch 267 not taken.
✓ Branch 268 taken 116 times.
✗ Branch 269 not taken.
✓ Branch 270 taken 116 times.
✗ Branch 271 not taken.
✓ Branch 272 taken 116 times.
✗ Branch 273 not taken.
✓ Branch 274 taken 116 times.
✗ Branch 275 not taken.
✓ Branch 276 taken 116 times.
✗ Branch 277 not taken.
✓ Branch 278 taken 116 times.
✗ Branch 279 not taken.
✓ Branch 280 taken 116 times.
✗ Branch 281 not taken.
✓ Branch 282 taken 116 times.
✗ Branch 283 not taken.
✓ Branch 284 taken 116 times.
✗ Branch 285 not taken.
✓ Branch 286 taken 116 times.
✗ Branch 287 not taken.
✓ Branch 288 taken 116 times.
✗ Branch 289 not taken.
✓ Branch 290 taken 116 times.
✗ Branch 291 not taken.
✓ Branch 292 taken 116 times.
✗ Branch 293 not taken.
✓ Branch 294 taken 116 times.
✗ Branch 295 not taken.
✓ Branch 296 taken 116 times.
✗ Branch 297 not taken.
✓ Branch 298 taken 116 times.
✗ Branch 299 not taken.
✓ Branch 300 taken 116 times.
✗ Branch 301 not taken.
✓ Branch 302 taken 116 times.
✗ Branch 303 not taken.
✓ Branch 304 taken 116 times.
✗ Branch 305 not taken.
✓ Branch 306 taken 116 times.
✗ Branch 307 not taken.
✓ Branch 308 taken 116 times.
✗ Branch 309 not taken.
✓ Branch 310 taken 116 times.
✗ Branch 311 not taken.
✓ Branch 312 taken 116 times.
✗ Branch 313 not taken.
✓ Branch 314 taken 116 times.
✗ Branch 315 not taken.
✓ Branch 316 taken 116 times.
✗ Branch 317 not taken.
✓ Branch 318 taken 116 times.
✗ Branch 319 not taken.
✓ Branch 320 taken 116 times.
✗ Branch 321 not taken.
✓ Branch 322 taken 116 times.
✗ Branch 323 not taken.
✓ Branch 324 taken 116 times.
✗ Branch 325 not taken.
✓ Branch 326 taken 116 times.
✗ Branch 327 not taken.
✓ Branch 328 taken 116 times.
✗ Branch 329 not taken.
✓ Branch 330 taken 116 times.
✗ Branch 331 not taken.
✓ Branch 332 taken 116 times.
✗ Branch 333 not taken.
✓ Branch 334 taken 116 times.
✗ Branch 335 not taken.
✓ Branch 336 taken 116 times.
✗ Branch 337 not taken.
✓ Branch 338 taken 116 times.
✗ Branch 339 not taken.
✓ Branch 340 taken 116 times.
✗ Branch 341 not taken.
✓ Branch 342 taken 116 times.
✗ Branch 343 not taken.
✓ Branch 344 taken 116 times.
✗ Branch 345 not taken.
✓ Branch 346 taken 116 times.
✗ Branch 347 not taken.
✓ Branch 348 taken 116 times.
✗ Branch 349 not taken.
✓ Branch 350 taken 116 times.
✗ Branch 351 not taken.
✓ Branch 352 taken 116 times.
✗ Branch 353 not taken.
✓ Branch 354 taken 116 times.
✗ Branch 355 not taken.
✓ Branch 356 taken 116 times.
✗ Branch 357 not taken.
✓ Branch 358 taken 116 times.
✗ Branch 359 not taken.
✓ Branch 360 taken 116 times.
✗ Branch 361 not taken.
✓ Branch 362 taken 116 times.
✗ Branch 363 not taken.
✓ Branch 364 taken 116 times.
✗ Branch 365 not taken.
✓ Branch 366 taken 116 times.
✗ Branch 367 not taken.
✓ Branch 368 taken 116 times.
✗ Branch 369 not taken.
✓ Branch 370 taken 116 times.
✗ Branch 371 not taken.
✓ Branch 372 taken 116 times.
✗ Branch 373 not taken.
✗ Branch 374 not taken.
✗ Branch 375 not taken.
116 static std::set<std::string> banned_extensions = {".xlm",".caction",".8ck", ".actc",".a6p", ".m3g",".run",".workflow",".otm",".apk",".fxp",".73k",".0xe",".exe",".cmd",".jsx",".scar",".wcm",".jar",".ebs2",".ipa",".xap",".ba_",".ac",".bin",".vlx",".icd",".elf",".xbap",".89k",".widget",".a7r",".ex_",".zl9",".cgi",".scr",".coffee",".ahk",".plsc",".air",".ear",".app",".scptd",".xys",".hms",".cyw",".ebm",".pwc",".xqt",".msl",".seed",".vexe",".ebs",".mcr",".gpu",".celx",".wsh",".frs",".vxp",".action",".com",".out",".gadget",".command",".script",".rfu",".tcp",".widget",".ex4",".bat",".cof",".phar",".rxe",".scb",".ms",".isu",".fas",".mlx",".gpe",".mcr",".mrp",".u3p",".js",".acr",".epk",".exe1",".jsf",".rbf",".rgs",".vpm",".ecf",".hta",".dld",".applescript",".prg",".pyc",".spr",".nexe",".server",".appimage",".pyo",".dek",".mrc",".fpi",".rpj",".iim",".vbs",".pif",".mel",".scpt",".csh",".paf",".ws",".mm",".acc",".ex5",".mac",".plx",".snap",".ps1",".vdo",".mxe",".gs",".osx",".sct",".wiz",".x86",".e_e",".fky",".prg",".fas",".azw2",".actm",".cel",".tiapp",".thm",".kix",".wsf",".vbe",".lo",".ls",".tms",".ezs",".ds",".n",".esh",".vbscript",".arscript",".qit",".pex",".dxl",".wpm",".s2a",".sca",".prc",".shb",".rbx",".jse",".beam",".udf",".mem",".kx",".ksh",".rox",".upx",".ms",".mam",".btm",".es",".asb",".ipf",".mio",".sbs",".hpf",".ita",".eham",".ezt",".dmc",".qpx",".ore",".ncl",".exopc",".smm",".pvd",".ham",".wpk"};
35579
35580 // Any extension other than banned ones, including no extension, is allowed.
35581 2 bool validate_userfile_extension(string const& path)
35582 {
35583
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 std::string ext = std::filesystem::path(path).extension().string();
35584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 return banned_extensions.find(ext) == banned_extensions.end();
35585 2 }
35586
35587 2 bool FFScript::get_scriptfile_path(char* buf, const char* path)
35588 {
35589
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 while((path[0] == '/' || path[0] == '\\') && path[0]) ++path;
35590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(path[0])
35591 2 sprintf(buf, "%s%c%s", qst_files_path, PATH_SLASH, path);
35592 else sprintf(buf, "%s", qst_files_path);
35593 2 return true;
35594 }
35595
35596 void check_file_error(int32_t ref)
35597 {
35598 if(user_file* f = checkFile(ref, "", true, true))
35599 {
35600 int32_t err = ferror(f->file);
35601 if(err != 0)
35602 {
35603 Z_scripterrlog("File with UID '%ld' encountered an error.\n", ref);
35604 Z_scripterrlog("File error: %s\n", strerror(err));
35605 }
35606 }
35607 }
35608
35609 2 void FFScript::do_fopen(const bool v, const char* f_mode)
35610 {
35611 2 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
35612 2 string filename_str;
35613
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 ArrayH::getString(arrayptr, filename_str, 512);
35614
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 regulate_path(filename_str);
35615 2 ri->d[rEXP1] = 0L; //Presume failure; update to 10000L on success
35616
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(!valid_file(filename_str))
35617 {
35618 Z_scripterrlog("Path '%s' empty or points to a directory; must point to a file!\n",filename_str.c_str());
35619 return;
35620 }
35621
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(!validate_userfile_extension(filename_str))
35622 {
35623 Z_scripterrlog("Cannot open/create file with extension '%s'.\n", get_ext(filename_str).c_str());
35624 return;
35625 }
35626
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(filename_str.find("../") != string::npos
35627
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 || filename_str.find("..\\") != string::npos)
35628 {
35629 Z_scripterrlog("Error: Script attempted to go up a directory in file load '%s'\n", filename_str.c_str());
35630 return;
35631 }
35632 2 char buf[2048+1] = {0};
35633 2 FFCore.get_scriptfile_path(buf, filename_str.c_str());
35634
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 user_file* f = checkFile(ri->fileref, "Open()", false, true);
35635
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!f) //auto-allocate
35636 {
35637
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 ri->fileref = get_free_file();
35638
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 f = checkFile(ri->fileref, "Open()", false, true);
35639 2 }
35640 2 ri->d[rEXP2] = ri->fileref; //Returns to the variable!
35641
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(f)
35642 {
35643
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 f->close(); //Close the old FILE* before overwriting it!
35644 2 bool create = false;
35645
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
5 for(int32_t q = 0; f_mode[q]; ++q)
35646 {
35647
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
4 if(f_mode[q] == 'w' || f_mode[q] == 'a')
35648 {
35649 1 create = true;
35650 1 break;
35651 }
35652 3 }
35653
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 if(!create || create_path(buf))
35654 {
35655
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 f->file = fopen(buf, f_mode);
35656
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 fflush(f->file);
35657
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 zc_chmod(buf, SCRIPT_FILE_MODE);
35658
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 f->setPath(buf);
35659 //r+; read-write, will not create if does not exist, will not delete content if does exist.
35660 //w+; read-write, will create if does not exist, will delete all content if does exist.
35661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(f->file)
35662 {
35663 ri->d[rEXP1] = 10000L; //Success
35664 return;
35665 }
35666 1 }
35667 else
35668 {
35669
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 Z_scripterrlog("Script failed to create directories for file path '%s'.\n", filename_str.c_str());
35670 1 return;
35671 }
35672 1 }
35673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 }
35674
35675 void FFScript::do_fremove()
35676 {
35677 if(user_file* f = checkFile(ri->fileref, "Remove()", true))
35678 {
35679 zprint2("Removing file %d\n", ri->fileref);
35680 ri->d[rEXP1] = f->do_remove() ? 0L : 10000L;
35681 }
35682 else ri->d[rEXP1] = 0L;
35683 }
35684
35685 void FFScript::do_fclose()
35686 {
35687 if(user_file* f = checkFile(ri->fileref, "Close()", false, true))
35688 {
35689 f->close();
35690 }
35691 //No else. If invalid, no error is thrown.
35692 }
35693
35694 void FFScript::do_allocate_file()
35695 {
35696 //Get a file and return it
35697 ri->fileref = get_free_file();
35698 ri->d[rEXP2] = ri->fileref; //Return to ptr
35699 ri->d[rEXP1] = (ri->d[rEXP2] == 0 ? 0L : 10000L);
35700 }
35701
35702 1 void FFScript::do_deallocate_file()
35703 {
35704 1 user_file* f = checkFile(ri->fileref, "Free()", false, true);
35705
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(f) f->clear();
35706 1 }
35707
35708 void FFScript::do_file_isallocated() //Returns true if file is allocated
35709 {
35710 user_file* f = checkFile(ri->fileref, "isAllocated()", false, true);
35711 ri->d[rEXP1] = (f) ? 10000L : 0L;
35712 }
35713
35714 void FFScript::do_file_isvalid() //Returns true if file is allocated and has an open FILE*
35715 {
35716 user_file* f = checkFile(ri->fileref, "isValid()", true, true);
35717 ri->d[rEXP1] = (f) ? 10000L : 0L;
35718 }
35719
35720 1 void FFScript::do_fflush()
35721 {
35722 1 ri->d[rEXP1] = 0L;
35723
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(user_file* f = checkFile(ri->fileref, "Flush()", true))
35724 {
35725 if(!fflush(f->file))
35726 ri->d[rEXP1] = 10000L;
35727 check_file_error(ri->fileref);
35728 }
35729 1 }
35730
35731 void FFScript::do_file_readchars()
35732 {
35733 if(user_file* f = checkFile(ri->fileref, "ReadChars()", true))
35734 {
35735 uint32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
35736 int32_t count = get_register(sarg2) / 10000;
35737 if(count == 0) return;
35738 int32_t arrayptr = get_register(sarg1) / 10000;
35739 ArrayManager am(arrayptr);
35740 int32_t sz = am.size();
35741 if(sz < 0)
35742 return;
35743 if(pos >= sz)
35744 {
35745 Z_scripterrlog("Pos (%d) passed to %s is outside the bounds of array %d. Aborting.\n", pos, "ReadChars()", arrayptr);
35746 return;
35747 }
35748 if(count < 0 || unsigned(count) > sz-pos) count = sz-pos;
35749 int32_t limit = pos+count;
35750 char c;
35751 word q;
35752 ri->d[rEXP1] = 0;
35753 for(q = pos; q < limit; ++q)
35754 {
35755 c = fgetc(f->file);
35756 if(feof(f->file) || ferror(f->file))
35757 break;
35758 if(c <= 0)
35759 break;
35760 am.set(q,c * 10000L);
35761 ++ri->d[rEXP1]; //Don't count nullchar towards length
35762 }
35763 if(q >= limit)
35764 {
35765 --q;
35766 --ri->d[rEXP1];
35767 ungetc(am.get(q), f->file); //Put the character back before overwriting it
35768 }
35769 am.set(q,0); //Force null-termination
35770 ri->d[rEXP1] *= 10000L;
35771 check_file_error(ri->fileref);
35772 return;
35773 }
35774 ri->d[rEXP1] = 0L;
35775 }
35776 void FFScript::do_file_readbytes()
35777 {
35778 if(user_file* f = checkFile(ri->fileref, "ReadBytes()", true))
35779 {
35780 uint32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
35781 int32_t count = get_register(sarg2) / 10000;
35782 if(count == 0) return;
35783 int32_t arrayptr = get_register(sarg1) / 10000;
35784 ArrayManager am(arrayptr);
35785 int32_t sz = am.size();
35786 if(sz < 0)
35787 return;
35788 if(pos >= sz)
35789 {
35790 Z_scripterrlog("Pos (%d) passed to %s is outside the bounds of array %d. Aborting.\n", pos, "ReadBytes()", arrayptr);
35791 return;
35792 }
35793 if(count < 0 || unsigned(count) > sz-pos) count = sz-pos;
35794 std::vector<uint8_t> data(count);
35795 ri->d[rEXP1] = 10000L * fread((void*)&(data[0]), 1, count, f->file);
35796 for(int32_t q = 0; q < count; ++q)
35797 {
35798 am.set(q+pos, 10000L * data[q]);
35799 }
35800 check_file_error(ri->fileref);
35801 return;
35802 }
35803 ri->d[rEXP1] = 0L;
35804 }
35805 void FFScript::do_file_readstring()
35806 {
35807 if(user_file* f = checkFile(ri->fileref, "ReadString()", true))
35808 {
35809 int32_t arrayptr = get_register(sarg1) / 10000;
35810 ArrayManager am(arrayptr);
35811 int32_t sz = am.size();
35812 if(sz < 0)
35813 return;
35814 int32_t limit = sz;
35815 int32_t c;
35816 word q;
35817 ri->d[rEXP1] = 0;
35818 for(q = 0; q < limit; ++q)
35819 {
35820 c = fgetc(f->file);
35821 if(feof(f->file) || ferror(f->file))
35822 break;
35823 if(c <= 0)
35824 break;
35825 am.set(q,c * 10000L);
35826 ++ri->d[rEXP1]; //Don't count nullchar towards length
35827 if(c == '\n')
35828 {
35829 ++q;
35830 break;
35831 }
35832 }
35833 if(q >= limit)
35834 {
35835 --q;
35836 --ri->d[rEXP1];
35837 ungetc(am.get(q), f->file); //Put the character back before overwriting it
35838 }
35839 am.set(q,0); //Force null-termination
35840 ri->d[rEXP1] *= 10000L;
35841 check_file_error(ri->fileref);
35842 return;
35843 }
35844 ri->d[rEXP1] = 0L;
35845 }
35846 void FFScript::do_file_readints()
35847 {
35848 if(user_file* f = checkFile(ri->fileref, "ReadInts()", true))
35849 {
35850 uint32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
35851 int32_t count = get_register(sarg2) / 10000;
35852 if(count == 0) return;
35853 int32_t arrayptr = get_register(sarg1) / 10000;
35854 ArrayManager am(arrayptr);
35855 int32_t sz = am.size();
35856 if(sz < 0)
35857 return;
35858 if(pos >= sz)
35859 {
35860 Z_scripterrlog("Pos (%d) passed to %s is outside the bounds of array %d. Aborting.\n", pos, "ReadInts()", arrayptr);
35861 return;
35862 }
35863 if(count < 0 || unsigned(count) > sz-pos) count = sz-pos;
35864
35865 std::vector<int32_t> data(count);
35866 ri->d[rEXP1] = 10000L * fread((void*)&(data[0]), 4, count, f->file);
35867 for(int32_t q = 0; q < count; ++q)
35868 {
35869 am.set(q+pos,data[q]);
35870 }
35871 check_file_error(ri->fileref);
35872 return;
35873 }
35874 ri->d[rEXP1] = 0L;
35875 }
35876 void FFScript::do_file_writechars()
35877 {
35878 if(user_file* f = checkFile(ri->fileref, "WriteChars()", true))
35879 {
35880 int32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
35881 int32_t count = get_register(sarg2) / 10000;
35882 if(count == 0) return;
35883 if(count == -1 || count > (MAX_ZC_ARRAY_SIZE-pos)) count = MAX_ZC_ARRAY_SIZE-pos;
35884 int32_t arrayptr = get_register(sarg1) / 10000;
35885 string output;
35886 ArrayH::getString(arrayptr, output, count, pos);
35887 uint32_t q = 0;
35888 for(; q < output.length(); ++q)
35889 {
35890 if(fputc(output[q], f->file)<0)
35891 break;
35892 }
35893 ri->d[rEXP1] = q * 10000L;
35894 check_file_error(ri->fileref);
35895 return;
35896 }
35897 ri->d[rEXP1] = 0L;
35898 }
35899
35900 void FFScript::do_file_writebytes()
35901 {
35902 if(user_file* f = checkFile(ri->fileref, "WriteBytes()", true))
35903 {
35904 uint32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
35905 int32_t arg = get_register(sarg2) / 10000;
35906 if(arg == 0) return;
35907 uint32_t count = ((arg<0 || unsigned(arg) >(MAX_ZC_ARRAY_SIZE - pos)) ? MAX_ZC_ARRAY_SIZE - pos : unsigned(arg));
35908 int32_t arrayptr = get_register(sarg1) / 10000;
35909 string output;
35910 ArrayManager am(arrayptr);
35911 if(am.invalid()) return;
35912 int32_t sz = am.size();
35913 if(sz < 0)
35914 return;
35915 if(pos >= sz)
35916 {
35917 Z_scripterrlog("Pos (%d) passed to %s is outside the bounds of array %d. Aborting.\n", pos, "WriteBytes()", arrayptr);
35918 return;
35919 }
35920 if(count < 0 || unsigned(count) > sz-pos) count = sz-pos;
35921 std::vector<uint8_t> data(count);
35922 for(uint32_t q = 0; q < count; ++q)
35923 {
35924 data[q] = am.get(q+pos) / 10000;
35925 }
35926 ri->d[rEXP1] = 10000L * fwrite((const void*)&(data[0]), 1, count, f->file);
35927 check_file_error(ri->fileref);
35928 return;
35929 }
35930 ri->d[rEXP1] = 0L;
35931 }
35932 279 void FFScript::do_file_writestring()
35933 {
35934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279 times.
279 if(user_file* f = checkFile(ri->fileref, "WriteString()", true))
35935 {
35936 int32_t arrayptr = get_register(sarg1) / 10000;
35937 string output;
35938 ArrayH::getString(arrayptr, output, ZSCRIPT_MAX_STRING_CHARS);
35939 uint32_t q = 0;
35940 for(; q < output.length(); ++q)
35941 {
35942 if(fputc(output[q], f->file)<0)
35943 break;
35944 }
35945 ri->d[rEXP1] = q * 10000L;
35946 check_file_error(ri->fileref);
35947 return;
35948 }
35949 279 ri->d[rEXP1] = 0L;
35950 279 }
35951 void FFScript::do_file_writeints()
35952 {
35953 if(user_file* f = checkFile(ri->fileref, "WriteInts()", true))
35954 {
35955 uint32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
35956 int32_t count = get_register(sarg2) / 10000;
35957 if(count == 0) return;
35958 int32_t arrayptr = get_register(sarg1) / 10000;
35959 ArrayManager am(arrayptr);
35960 if(am.invalid()) return;
35961 int32_t sz = am.size();
35962 if(sz < 0)
35963 return;
35964 if(pos >= sz)
35965 {
35966 Z_scripterrlog("Pos (%d) passed to %s is outside the bounds of array %d. Aborting.\n", pos, "WriteInts()", arrayptr);
35967 return;
35968 }
35969
35970 if(count < 0 || unsigned(count) > sz-pos) count = sz-pos;
35971 std::vector<int32_t> data(count);
35972 for(int32_t q = 0; q < count; ++q)
35973 {
35974 data[q] = am.get(q+pos);
35975 }
35976 ri->d[rEXP1] = 10000L * fwrite((const void*)&(data[0]), 4, count, f->file);
35977 check_file_error(ri->fileref);
35978 return;
35979 }
35980 ri->d[rEXP1] = 0L;
35981 }
35982
35983 void FFScript::do_file_getchar()
35984 {
35985 if(user_file* f = checkFile(ri->fileref, "GetChar()", true))
35986 {
35987 ri->d[rEXP1] = fgetc(f->file) * 10000L;
35988 check_file_error(ri->fileref);
35989 return;
35990 }
35991 ri->d[rEXP1] = -10000L; //-1 == EOF; error value
35992 }
35993 void FFScript::do_file_putchar()
35994 {
35995 if(user_file* f = checkFile(ri->fileref, "PutChar()", true))
35996 {
35997 int32_t c = get_register(sarg1) / 10000;
35998 if(char(c) != c)
35999 {
36000 Z_scripterrlog("Invalid character val %d passed to PutChar(); value will overflow.", c);
36001 c = char(c);
36002 }
36003 ri->d[rEXP1] = fputc(c, f->file) * 10000L;
36004 check_file_error(ri->fileref);
36005 return;
36006 }
36007 ri->d[rEXP1] = -10000L; //-1 == EOF; error value
36008 }
36009 void FFScript::do_file_ungetchar()
36010 {
36011 if(user_file* f = checkFile(ri->fileref, "UngetChar()", true))
36012 {
36013 int32_t c = get_register(sarg1) / 10000;
36014 if(char(c) != c)
36015 {
36016 Z_scripterrlog("Invalid character val %d passed to UngetChar(); value will overflow.", c);
36017 c = char(c);
36018 }
36019 ri->d[rEXP1] = ungetc(c,f->file) * 10000L;
36020 check_file_error(ri->fileref);
36021 return;
36022 }
36023 ri->d[rEXP1] = -10000L; //-1 == EOF; error value
36024 }
36025
36026 void FFScript::do_file_seek()
36027 {
36028 if(user_file* f = checkFile(ri->fileref, "Seek()", true))
36029 {
36030 int32_t pos = get_register(sarg1); //NOT /10000 -V
36031 int32_t origin = get_register(sarg2) ? SEEK_CUR : SEEK_SET;
36032 ri->d[rEXP1] = fseek(f->file, pos, origin) ? 0L : 10000L;
36033 check_file_error(ri->fileref);
36034 return;
36035 }
36036 ri->d[rEXP1] = 0;
36037 }
36038 void FFScript::do_file_rewind()
36039 {
36040 if(user_file* f = checkFile(ri->fileref, "Rewind()", true))
36041 {
36042 //fseek(f->file, 0L, SEEK_END);
36043 rewind(f->file);
36044 check_file_error(ri->fileref);
36045 }
36046 }
36047 void FFScript::do_file_clearerr()
36048 {
36049 if(user_file* f = checkFile(ri->fileref, "ClearError()", true))
36050 {
36051 clearerr(f->file);
36052 }
36053 }
36054
36055 void FFScript::do_file_geterr()
36056 {
36057 if(user_file* f = checkFile(ri->fileref, "GetError()", true))
36058 {
36059 int32_t err = ferror(f->file);
36060 int32_t arrayptr = get_register(sarg1) / 10000;
36061 if(err)
36062 {
36063 string error = strerror(err);
36064 ArrayH::setArray(arrayptr, error);
36065 }
36066 else
36067 {
36068 ArrayH::setArray(arrayptr, "\0");
36069 }
36070 }
36071 }
36072 ///----------------------------------------------------------------------------------------------------
36073 //Directory
36074
36075 void FFScript::do_directory_get()
36076 {
36077 if(user_dir* dr = checkDir(ri->directoryref, "GetFilename()", true))
36078 {
36079 int32_t indx = get_register(sarg1) / 10000L;
36080 int32_t arrayptr = get_register(sarg2) / 10000L;
36081 char buf[2048] = {0};
36082 set_register(sarg1, dr->get(indx, buf) ? 10000L : 0L);
36083 if(ArrayH::setArray(arrayptr, string(buf)) == SH::_Overflow)
36084 Z_scripterrlog("Array supplied to 'directory->GetFilename()' not large enough\n");
36085 }
36086 else set_register(sarg1, 0L);
36087 }
36088
36089 void FFScript::do_directory_reload()
36090 {
36091 if(user_dir* dr = checkDir(ri->directoryref, "Reload()", true))
36092 {
36093 dr->refresh();
36094 }
36095 }
36096
36097 void FFScript::do_directory_free()
36098 {
36099 if(user_dir* dr = checkDir(ri->directoryref, "Free()", true))
36100 {
36101 dr->clear();
36102 }
36103 }
36104
36105 ///----------------------------------------------------------------------------------------------------
36106
36107
36108 void FFScript::do_write_bitmap()
36109 {
36110 // for ( int32_t q = 0; q < 16; q++)
36111 // zprint("do_write_bitmap stack sp+%d: %d\n", q, SH::read_stack(ri->sp+q));
36112 int32_t arrayptr = get_register(sarg2) / 10000;
36113 string filename_str;
36114
36115 ArrayH::getString(arrayptr, filename_str, 512);
36116 int32_t ref = ri->bitmapref-10;
36117 // zprint("WriteBitmap() filename is %s\n",filename_str.c_str());
36118 // zprint("WriteBitmap ri->bitmapref is: %d\n",ref );
36119 if ( ref <= 0 )
36120 {
36121 if (ref == -2 )
36122 {
36123 save_bitmap(filename_str.c_str(), framebuf, RAMpal);
36124 // zprint("Wrote image file %s\n",filename_str.c_str());
36125 }
36126 else
36127 {
36128 Z_scripterrlog("WriteBitmap() failed to write image file %s\n",filename_str.c_str());
36129 }
36130 }
36131 else if ( ref >= 7 )
36132 {
36133 if ( scb.script_created_bitmaps[ref].u_bmp )
36134 {
36135 save_bitmap(filename_str.c_str(), scb.script_created_bitmaps[ri->bitmapref-10].u_bmp, RAMpal);
36136 // zprint("Wrote image file %s\n",filename_str.c_str());
36137 }
36138 else
36139 {
36140 Z_scripterrlog("WriteBitmap() failed to write image file %s\n",filename_str.c_str());
36141 }
36142 }
36143 else
36144 {
36145 if ( zscriptDrawingRenderTarget->GetBitmapPtr(ref) )
36146 {
36147 save_bitmap(filename_str.c_str(), zscriptDrawingRenderTarget->GetBitmapPtr(ref), RAMpal);
36148 // zprint("Wrote image file %s\n",filename_str.c_str());
36149 }
36150 else
36151 {
36152 Z_scripterrlog("WriteBitmap() failed to write image file %s\n",filename_str.c_str());
36153 }
36154 }
36155 }
36156
36157 void FFScript::set_sarg1(int32_t v)
36158 {
36159 set_register(sarg1, v);
36160 }
36161
36162 //script_bitmaps scb;
36163
36164 125 int32_t FFScript::do_allocate_bitmap()
36165 {
36166 125 return FFCore.get_free_bitmap();
36167 }
36168 10 void FFScript::do_isvalidbitmap()
36169 {
36170 10 int32_t UID = get_register(sarg1);
36171 //zprint("isValidBitmap() bitmap pointer value is %d\n", UID);
36172
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
10 if ( UID <= 0 ) set_register(sarg1, 0);
36173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 else if ( scb.script_created_bitmaps[UID-10].u_bmp )
36174 5 set_register(sarg1, 10000);
36175 else set_register(sarg1, 0);
36176 10 }
36177 43 void FFScript::do_isallocatedbitmap()
36178 {
36179 43 int32_t UID = get_register(sarg1);
36180 //zprint("isAllocatedBitmap() bitmap pointer value is %d\n", UID);
36181
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 42 times.
43 if ( UID <= 0 ) set_register(sarg1, 0);
36182 else
36183 {
36184 42 set_register(sarg1, (scb.script_created_bitmaps[UID-10].reserved()) ? 10000L : 0L);
36185 /*
36186 UID-=10;
36187 if ( UID <= highest_valid_user_bitmap() || UID < firstUserGeneratedBitmap)
36188 set_register(sarg1, 10000);
36189 else set_register(sarg1, 0);
36190 */
36191
36192 }
36193 43 }
36194
36195 226 void FFScript::user_bitmaps_init()
36196 {
36197 226 scb.clear();
36198 226 }
36199
36200 3670 int32_t FFScript::do_create_bitmap()
36201 {
36202 //zprint("Begin running FFCore.do_create_bitmap()\n");
36203 //CreateBitmap(h,w)
36204 3670 int32_t w = (ri->d[rINDEX2] / 10000);
36205 3670 int32_t h = (ri->d[rINDEX]/10000);
36206
1/2
✓ Branch 0 taken 3670 times.
✗ Branch 1 not taken.
3670 if ( get_qr(qr_OLDCREATEBITMAP_ARGS) )
36207 {
36208 //flip height and width
36209 h = h ^ w;
36210 w = h ^ w;
36211 h = h ^ w;
36212 }
36213
36214 3670 return create_user_bitmap_ex(h,w,8);
36215 }
36216
36217 3670 int32_t FFScript::create_user_bitmap_ex(int32_t w, int32_t h, int32_t d = 8)
36218 {
36219 3670 int32_t id = get_free_bitmap();
36220
1/2
✓ Branch 0 taken 3670 times.
✗ Branch 1 not taken.
3670 if ( id > 0 )
36221 {
36222 3670 user_bitmap* bmp = &(scb.script_created_bitmaps[id-10]);
36223 3670 bmp->width = w;
36224 3670 bmp->height = h;
36225 3670 bmp->depth = d;
36226 3670 bmp->u_bmp = create_bitmap_ex(d,w,h);
36227 3670 clear_bitmap(bmp->u_bmp);
36228 3670 }
36229 3670 return id;
36230 }
36231
36232 616532 BITMAP* FFScript::GetScriptBitmap(int32_t id, bool skipError)
36233 {
36234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 616532 times.
616532 switch(id)
36235 {
36236 case rtSCREEN:
36237 case rtBMP0:
36238 case rtBMP1:
36239 case rtBMP2:
36240 case rtBMP3:
36241 case rtBMP4:
36242 case rtBMP5:
36243 case rtBMP6: //old system bitmaps (render targets)
36244 {
36245 return zscriptDrawingRenderTarget->GetBitmapPtr(id);
36246 }
36247 default:
36248 {
36249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 616532 times.
616532 if(user_bitmap* b = checkBitmap(id+10, NULL, true, skipError))
36250 {
36251 616532 return b->u_bmp;
36252 }
36253 else return NULL;
36254 }
36255 }
36256 616532 }
36257
36258 3795 int32_t FFScript::get_free_bitmap(bool skipError)
36259 {
36260 3795 user_bitmap* bmps = scb.script_created_bitmaps;
36261
1/2
✓ Branch 0 taken 63470 times.
✗ Branch 1 not taken.
63470 for(int32_t q = MIN_USER_BITMAPS; q < MAX_USER_BITMAPS; ++q)
36262 {
36263
2/2
✓ Branch 0 taken 59675 times.
✓ Branch 1 taken 3795 times.
63470 if(!bmps[q].reserved())
36264 {
36265 3795 bmps[q].reserve();
36266 3795 return q+10;
36267 }
36268 59675 }
36269 if(!skipError) Z_scripterrlog("get_free_bitmap() could not find a valid free bitmap pointer!\n");
36270 return 0;
36271 3795 }
36272
36273 3512 void FFScript::do_deallocate_bitmap()
36274 {
36275
1/2
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
3512 if(isSystemBitref(ri->bitmapref))
36276 {
36277 return; //Don't attempt to deallocate system bitmaps!
36278 }
36279 3512 user_bitmap* b = checkBitmap(ri->bitmapref, "Free()", false, true);
36280
1/2
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
3512 if(b)
36281 {
36282 3512 b->free();
36283 3512 }
36284 3512 }
36285
36286 3658 bool FFScript::isSystemBitref(int32_t ref)
36287 {
36288
1/2
✓ Branch 0 taken 3658 times.
✗ Branch 1 not taken.
3658 switch(ref-10)
36289 {
36290 case rtSCREEN:
36291 case rtBMP0:
36292 case rtBMP1:
36293 case rtBMP2:
36294 case rtBMP3:
36295 case rtBMP4:
36296 case rtBMP5:
36297 case rtBMP6:
36298 return true;
36299 }
36300 3658 return false;
36301 3658 }
36302
36303 ///----------------------------------------------------------------------------------------------------
36304
36305 void FFScript::set_screenwarpReturnY(mapscr *m, int32_t d, int32_t value)
36306 {
36307 int32_t y = vbound(value, 0, 255); //should be screen hight max, except that we may be able to move the subscreen.
36308 m->warpreturny[d] = y;
36309 }
36310
36311 void FFScript::set_screendoor(mapscr *m, int32_t d, int32_t value)
36312 {
36313 int32_t dr = vbound(d,0,3);
36314 int32_t doortype = vbound(value,0,14);
36315 m->door[dr] = doortype;
36316 }
36317
36318
36319 void FFScript::set_screenenemy(mapscr *m, int32_t index, int32_t value)
36320 {
36321 int32_t enem_indx = vbound(index,0,9);
36322 m->enemy[enem_indx] = vbound(value,0,511);
36323 }
36324 void FFScript::set_screenlayeropacity(mapscr *m, int32_t d, int32_t value)
36325 {
36326 int32_t layer = vbound(d,0,6); int32_t op;
36327 if ( value <= 64 ) op = 64;
36328 else op = 128;
36329 m->layeropacity[layer] = op;
36330 }
36331 void FFScript::set_screensecretcombo(mapscr *m, int32_t d, int32_t value)
36332 {
36333 int32_t indx = vbound(value,0,127);
36334 int32_t cmb = vbound(value,0,MAXCOMBOS);
36335 m->secretcombo[indx] = cmb;
36336 }
36337 void FFScript::set_screensecretcset(mapscr *m, int32_t d, int32_t value)
36338 {
36339 int32_t indx = vbound(value,0,127);
36340 int32_t cs = vbound(value,0,15);
36341 m->secretcset[indx] = cs;
36342 }
36343 void FFScript::set_screensecretflag(mapscr *m, int32_t d, int32_t value)
36344 {
36345 int32_t indx = vbound(d,0,127);
36346 int32_t flag = vbound(value,0,MAX_FLAGS);
36347 m->secretflag[indx] = flag;
36348 }
36349 void FFScript::set_screenlayermap(mapscr *m, int32_t d, int32_t value)
36350 {
36351 int32_t layer = vbound(d, MIN_ZQ_LAYER, MAX_ZQ_LAYER);
36352 int32_t mp = vbound(value,0, (map_count-1));
36353 m->layermap[layer] = mp;
36354 }
36355 void FFScript::set_screenlayerscreen(mapscr *m, int32_t d, int32_t value)
36356 {
36357 int32_t layer = vbound(d, MIN_ZQ_LAYER, MAX_ZQ_LAYER);
36358 int32_t sc = vbound(value,0, 0x87);
36359 m->layerscreen[layer] = sc;
36360 }
36361 void FFScript::set_screenpath(mapscr *m, int32_t d, int32_t value)
36362 {
36363 int32_t indx = vbound(d,0,3);
36364 m->path[indx] = value;
36365 }
36366 void FFScript::set_screenwarpReturnX(mapscr *m, int32_t d, int32_t value)
36367 {
36368 int32_t x = vbound(value,0,255);
36369 m->warpreturnx[d] = x;
36370 }
36371
36372
36373 void FFScript::set_screenGuy(mapscr *m, int32_t value)
36374 {
36375 int32_t bloke = vbound(value,0,9);
36376 m->guy = bloke ;
36377 }
36378 void FFScript::set_screenString(mapscr *m, int32_t value)
36379 {
36380 int32_t string = vbound(value, 0, msg_count-1); //Sanity check to keep it within the legal string IDs.
36381 m->str = string;
36382 }
36383 void FFScript::set_screenRoomtype(mapscr *m, int32_t value)
36384 {
36385 int32_t r = vbound(value, rNONE, (rMAX-1));
36386 m->room = r;
36387 }
36388 void FFScript::set_screenEntryX(mapscr *m, int32_t value)
36389 {
36390 int32_t x = vbound(value,0,255);
36391 m->entry_x = x;
36392 }
36393 void FFScript::set_screenEntryY(mapscr *m, int32_t value)
36394 {
36395 int32_t y = vbound(value,0,255);
36396 m->entry_y = y;
36397 }
36398 void FFScript::set_screenitem(mapscr *m, int32_t value)
36399 {
36400 int32_t itm = vbound(value,0,MAXITEMS);
36401 m->item = itm;
36402 }
36403 void FFScript::set_screenundercombo(mapscr *m, int32_t value)
36404 {
36405 int32_t cmb = vbound(value,0,MAXCOMBOS);
36406 m->undercombo = cmb;
36407 }
36408 void FFScript::set_screenundercset(mapscr *m, int32_t value)
36409 {
36410 int32_t cs = vbound(value,0,15);
36411 m->undercset = cs;
36412 }
36413 void FFScript::set_screenatchall(mapscr *m, int32_t value)
36414 {
36415 //What are ALL of the catchalls and their max (used) values?
36416 int32_t ctch = vbound(value, 0, 65535); //It is a word type.
36417 m->catchall = ctch;
36418 }
36419
36420
36421 //One too many inputs here. -Z
36422
36423 1051 int32_t FFScript::GetQuestVersion()
36424 {
36425 1051 return QHeader.zelda_version;
36426 }
36427 720 int32_t FFScript::GetQuestBuild()
36428 {
36429 720 return QHeader.build;
36430 }
36431 int32_t FFScript::GetQuestSectionVersion(int32_t section)
36432 {
36433 return QHeader.zelda_version;
36434 }
36435
36436 int32_t FFScript::GetDefaultWeaponSprite(int32_t wpn_id)
36437 {
36438 switch (wpn_id)
36439 {
36440 case wNone:
36441 return 0;
36442
36443 case wSword: return 0;
36444 case wBeam: return 1;
36445 case wBrang: return 4;
36446 case wBomb: return 9;
36447 case wSBomb: return 75;
36448 case wLitBomb: return 7;
36449 case wLitSBomb: return 8;
36450 case wArrow: return 10;
36451 case wFire: return 12;
36452 case wWhistle: return 45; //blank, unused misc sprite
36453 case wBait: return 14;
36454 case wWand: return 15;
36455 case wMagic: return 16;
36456 case wCatching: return 45; //blank, unused misc sprite
36457 case wWind: return 13;
36458 case wRefMagic: return 16;
36459 case wRefFireball: return 17;
36460 case wRefRock: return 18;
36461 case wHammer: return 25;
36462 case wHookshot: return 26;
36463 case wHSHandle: return 28;
36464 case wHSChain: return 27;
36465 case wSSparkle: return 29;
36466 case wFSparkle: return 32;
36467 case wSmack: return 33;
36468 case wPhantom: return -1;
36469 case wCByrna: return 87;
36470 case wRefBeam: return 1;
36471 case wStomp: return 45; //blank, unused misc sprite
36472 case lwMax: return 45; //blank, unused misc sprite
36473 case wScript1: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 246; else return 0; }
36474 case wScript2: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 247; else return 0; }
36475 case wScript3: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 248; else return 0; }
36476 case wScript4: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 249; else return 0; }
36477 case wScript5: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 250; else return 0; }
36478 case wScript6: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 251; else return 0; }
36479 case wScript7: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 252; else return 0; }
36480 case wScript8: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 253; else return 0; }
36481 case wScript9: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 254; else return 0; }
36482 case wScript10: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 255; else return 0; }
36483
36484 case wIce: return 83;
36485 //Cannot use any of these weapons yet.
36486 //return -1;
36487
36488 case wEnemyWeapons:
36489 case ewFireball: return 17;
36490
36491 case ewArrow: return 19;
36492 case ewBrang: return 4;
36493 case ewSword: return 20;
36494 case ewRock: return 18;
36495 case ewMagic: return 21;
36496 case ewBomb: return 78;
36497 case ewSBomb: return 79;
36498 case ewLitBomb: return 76;
36499 case ewLitSBomb: return 77;
36500 case ewFireTrail: return 80;
36501 case ewFlame: return 35;
36502 case ewWind: return 36;
36503 case ewFlame2: return 81;
36504 case ewFlame2Trail: return 82;
36505 case ewIce: return 83;
36506 case ewFireball2: return 17; //fireball (rising)
36507
36508
36509 default: return -1; //No assign.
36510
36511 }
36512 }
36513
36514 //bitmap->GetPixel()
36515
36516
36517 int32_t FFScript::do_getpixel()
36518 {
36519 int32_t xoffset = 0, yoffset = 0;
36520 int32_t xoff = 0; int32_t yoff = 0;
36521 const bool brokenOffset= ( (get_er(er_BITMAPOFFSET)!=0)
36522 || (get_qr(qr_BITMAPOFFSETFIX)!=0) );
36523
36524 BITMAP *bitty = FFCore.GetScriptBitmap(ri->bitmapref-10);
36525 if(!bitty)
36526 {
36527 bitty = scrollbuf;
36528 }
36529 // draw to screen with subscreen offset
36530 if(!brokenOffset && ri->bitmapref == 10-1 )
36531 {
36532 xoffset = xoff;
36533 yoffset = 56; //should this be -56?
36534 }
36535 else
36536 {
36537 xoffset = 0;
36538 yoffset = 0;
36539 }
36540
36541 int32_t yv = ri->d[rINDEX2]/10000 + yoffset;
36542 int32_t ret = getpixel(bitty, ri->d[rINDEX]/10000, yv); //This is a palette index value.
36543 if(!get_qr(qr_BROKEN_GETPIXEL_VALUE))
36544 ret *= 10000;
36545 return ret;
36546 }
36547
36548 void FFScript::do_bmpcollision()
36549 {
36550 int32_t bmpref = SH::read_stack(ri->sp + 5);
36551 int32_t maskbmpref = SH::read_stack(ri->sp + 4);
36552 int32_t x = SH::read_stack(ri->sp + 3) / 10000;
36553 int32_t y = SH::read_stack(ri->sp + 2) / 10000;
36554 int32_t checkCol = SH::read_stack(ri->sp + 1) / 10000;
36555 int32_t maskCol = SH::read_stack(ri->sp + 0) / 10000;
36556 BITMAP *checkbit = FFCore.GetScriptBitmap(bmpref-10, true);
36557 BITMAP *maskbit = FFCore.GetScriptBitmap(maskbmpref-10, true);
36558 if(!(checkbit && maskbit))
36559 {
36560 set_register(sarg1, -10000);
36561 char buf1[16];
36562 char buf2[16];
36563 zc_itoa(bmpref, buf1);
36564 zc_itoa(maskbmpref, buf2);
36565 Z_scripterrlog("Invalid bitmap%s passed to 'bitmap->CountColor()': %s%s%s\n",
36566 (checkbit || maskbit) ? "" : "s", checkbit ? "" : buf1,
36567 (checkbit || maskbit) ? "" : ", ", maskbit ? "" : buf2);
36568 return;
36569 }
36570 int32_t ret = countColor(checkbit, maskbit, x, y, checkCol, maskCol);
36571 set_register(sarg1, ret*10000);
36572 }
36573
36574
36575 6554876 int32_t FFScript::loadMapData()
36576 {
36577 6554876 int32_t _map = (ri->d[rINDEX] / 10000);
36578 6554876 int32_t _scr = (ri->d[rINDEX2]/10000);
36579
2/2
✓ Branch 0 taken 6465817 times.
✓ Branch 1 taken 89059 times.
6554876 int32_t indx = (zc_max((_map)-1,0) * MAPSCRS + _scr);
36580 //zprint("LoadMapData Map Value: %d\n", _map);
36581 //zprint("LoadMapData Screen Value: %d\n", _scr);
36582 //zprint("LoadMapData Indx Value: %d\n", indx);
36583
2/4
✓ Branch 0 taken 6554876 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6554876 times.
6554876 if ( _map < 1 || _map > map_count )
36584 {
36585 Z_scripterrlog("Invalid Map ID passed to Game->LoadMapData: %d\n", _map);
36586 ri->mapsref = MAX_SIGNED_32;
36587 }
36588
2/4
✓ Branch 0 taken 6554876 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6554876 times.
6554876 else if ( _scr < 0 || _scr > 129 ) //0x00 to 0x81 -Z
36589 {
36590 Z_scripterrlog("Invalid Screen ID passed to Game->LoadMapData: %d\n", _scr);
36591 ri->mapsref = MAX_SIGNED_32;
36592 }
36593 6554876 else ri->mapsref = indx;
36594 //zprint("LoadMapData Screen set ri->mapsref to: %d\n", ri->mapsref);
36595 6554876 return ri->mapsref;
36596 }
36597
36598
36599 // Called when leaving a screen; deallocate arrays created by FFCs that aren't carried over
36600 6996587 void FFScript::deallocateZScriptArray(const int32_t ptrval)
36601 {
36602
1/2
✓ Branch 0 taken 6996587 times.
✗ Branch 1 not taken.
6996587 if(ptrval == 0) return;
36603
2/4
✓ Branch 0 taken 6996587 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6996587 times.
6996587 if(ptrval==0 || ptrval >= NUM_ZSCRIPT_ARRAYS)
36604 Z_scripterrlog("Script tried to deallocate memory at invalid address %ld\n", ptrval);
36605
1/2
✓ Branch 0 taken 6996587 times.
✗ Branch 1 not taken.
6996587 else if(ptrval<0)
36606 Z_scripterrlog("Script tried to deallocate memory at object-based address %ld\n", ptrval);
36607 else
36608 {
36609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6996587 times.
6996587 if(arrayOwner[ptrval].specOwned) return; //ignore this deallocation
36610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6996587 times.
6996587 if(arrayOwner[ptrval].specCleared) return;
36611 6996587 arrayOwner[ptrval].clear();
36612
36613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6996587 times.
6996587 if(localRAM[ptrval].Size() == 0)
36614 Z_scripterrlog("Script tried to deallocate memory that was not allocated at address %ld\n", ptrval);
36615 else
36616 {
36617 6996587 word size = localRAM[ptrval].Size();
36618 6996587 localRAM[ptrval].Clear();
36619
36620 // If this happens once per frame, it can drown out every other message. -L
36621 //Z_eventlog("Deallocated local array with address %ld, size %d\n", ptrval, size);
36622 6996587 size = size;
36623 }
36624 }
36625 6996587 }
36626
36627 433275 int32_t FFScript::get_screen_d(int32_t index1, int32_t index2)
36628 {
36629
3/4
✓ Branch 0 taken 433275 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 433272 times.
433275 if(index2 < 0 || index2 > 7)
36630 {
36631 3 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", index1);
36632 3 return 0;
36633 }
36634
36635 433272 return game->screen_d[index1][index2];
36636 433275 }
36637
36638 42105 void FFScript::set_screen_d(int32_t index1, int32_t index2, int32_t val)
36639 {
36640
2/4
✓ Branch 0 taken 42105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42105 times.
42105 if(index2 < 0 || index2 > 7)
36641 {
36642 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", index1);
36643 return;
36644 }
36645
36646 42105 game->screen_d[index1][index2] = val;
36647 42105 }
36648
36649 // If scr is currently being used as a layer, return that layer no.
36650 int32_t FFScript::whichlayer(int32_t scr)
36651 {
36652 for(int32_t i = 0; i < 6; i++)
36653 {
36654 if(scr == (tmpscr->layermap[i] - 1) * MAPSCRS + tmpscr->layerscreen[i])
36655 return i;
36656 }
36657
36658 return -1;
36659 }
36660
36661 void FFScript::do_zapout()
36662 {
36663 zapout();
36664 }
36665
36666 void FFScript::do_zapin(){ zapin(); }
36667
36668 void FFScript::do_openscreen() { openscreen(); }
36669 void FFScript::do_closescreen() { closescreen(); }
36670 void FFScript::do_openscreenshape()
36671 {
36672 int32_t shape = get_register(sarg1) / 10000;
36673 if(shape < 0 || shape >= bosMAX)
36674 {
36675 Z_scripterrlog("Invalid shape passed to %s! Valid range %d to %d. Using 'Circle' shape.\n", "Screen->OpeningWipe(int32_t)", 0, bosMAX-1);
36676 shape = bosCIRCLE;
36677 }
36678 openscreen(shape);
36679 }
36680 void FFScript::do_closescreenshape()
36681 {
36682 int32_t shape = get_register(sarg1) / 10000;
36683 if(shape < 0 || shape >= bosMAX)
36684 {
36685 Z_scripterrlog("Invalid shape passed to %s! Valid range %d to %d. Using 'Circle' shape.\n", "Screen->ClosingWipe(int32_t)", 0, bosMAX-1);
36686 shape = bosCIRCLE;
36687 }
36688 closescreen(shape);
36689 }
36690 void FFScript::do_wavyin() { wavyin(); }
36691 void FFScript::do_wavyout() { wavyout(false); }
36692
36693
36694 void FFScript::do_triggersecret(const bool v)
36695 {
36696 int32_t ID = vbound((SH::get_arg(sarg1, v) / 10000), 0, 255);
36697 mapscr *s = tmpscr;
36698 int32_t ft=0, checkflag; //Flag trigger, checked flag temp.
36699 bool putit = true; //Is set false with a mismatch (illegal value input).
36700 //Convert a flag type to a secret type. -Z
36701 switch(ID)
36702 {
36703 case mfANYFIRE:
36704 ft=sBCANDLE;
36705 break;
36706
36707 case mfSTRONGFIRE:
36708 ft=sRCANDLE;
36709 break;
36710
36711 case mfMAGICFIRE:
36712 ft=sWANDFIRE;
36713 break;
36714
36715 case mfDIVINEFIRE:
36716 ft=sDIVINEFIRE;
36717 break;
36718
36719 case mfARROW:
36720 ft=sARROW;
36721 break;
36722
36723 case mfSARROW:
36724 ft=sSARROW;
36725 break;
36726
36727 case mfGARROW:
36728 ft=sGARROW;
36729 break;
36730
36731 case mfSBOMB:
36732 ft=sSBOMB;
36733 break;
36734
36735 case mfBOMB:
36736 ft=sBOMB;
36737 break;
36738
36739 case mfBRANG:
36740 ft=sBRANG;
36741 break;
36742
36743 case mfMBRANG:
36744 ft=sMBRANG;
36745 break;
36746
36747 case mfFBRANG:
36748 ft=sFBRANG;
36749 break;
36750
36751 case mfWANDMAGIC:
36752 ft=sWANDMAGIC;
36753 break;
36754
36755 case mfREFMAGIC:
36756 ft=sREFMAGIC;
36757 break;
36758
36759 case mfREFFIREBALL:
36760 ft=sREFFIREBALL;
36761 break;
36762
36763 case mfSWORD:
36764 ft=sSWORD;
36765 break;
36766
36767 case mfWSWORD:
36768 ft=sWSWORD;
36769 break;
36770
36771 case mfMSWORD:
36772 ft=sMSWORD;
36773 break;
36774
36775 case mfXSWORD:
36776 ft=sXSWORD;
36777 break;
36778
36779 case mfSWORDBEAM:
36780 ft=sSWORDBEAM;
36781 break;
36782
36783 case mfWSWORDBEAM:
36784 ft=sWSWORDBEAM;
36785 break;
36786
36787 case mfMSWORDBEAM:
36788 ft=sMSWORDBEAM;
36789 break;
36790
36791 case mfXSWORDBEAM:
36792 ft=sXSWORDBEAM;
36793 break;
36794
36795 case mfHOOKSHOT:
36796 ft=sHOOKSHOT;
36797 break;
36798
36799 case mfWAND:
36800 ft=sWAND;
36801 break;
36802
36803 case mfHAMMER:
36804 ft=sHAMMER;
36805 break;
36806
36807 case mfSTRIKE:
36808 ft=sSTRIKE;
36809 break;
36810
36811 default:
36812 putit = false;
36813 break;
36814 }
36815 if ( putit )
36816 {
36817 for(int32_t iter=0; iter<2; ++iter)
36818 {
36819 for ( int32_t q = 0; q < 176; q++ )
36820 {
36821 if(iter==1) checkflag=s->sflag[q]; //Placed
36822 else checkflag=combobuf[s->data[q]].flag; //Inherent
36823 Z_message("checkflag is: %d\n", checkflag);
36824 al_trace("checkflag is: %d\n", checkflag);
36825
36826 Z_message("ID is: %ld\n", ID);
36827 al_trace("ID is: %d\n", ID);
36828 //cmbx = COMBOX(q);
36829 ////cmby = COMBOY(q);
36830
36831 //Placed flags
36832 if ( iter == 1 )
36833 {
36834 if ( s->sflag[q] == ID ) {
36835 screen_combo_modify_preroutine(s,q);
36836 s->data[q] = s->secretcombo[ft];
36837 s->cset[q] = s->secretcset[ft];
36838 s->sflag[q] = s->secretflag[ft];
36839 // newflag = s->secretflag[ft];
36840 screen_combo_modify_postroutine(s,q);
36841 }
36842 }
36843 //Inherent flags
36844 else
36845 {
36846 if ( combobuf[s->data[q]].flag == ID ) {
36847 screen_combo_modify_preroutine(s,q);
36848 s->data[q] = s->secretcombo[ft];
36849 s->cset[q] = s->secretcset[ft];
36850 //s->sflag[q] = s->secretflag[ft];
36851 screen_combo_modify_postroutine(s,q);
36852 }
36853
36854 }
36855 }
36856 }
36857 }
36858
36859 }
36860 //NPCData
36861
36862 //NPCData Getter Macros
36863
36864
36865
36866
36867 //NPCData-> Function
36868 #define GET_NPCDATA_FUNCTION_VAR_INT(member) \
36869 { \
36870 int32_t ID = get_register(sarg2) / 10000; \
36871 if(ID < 1 || ID > (MAXGUYS-1)) \
36872 set_register(sarg1, -10000); \
36873 else \
36874 set_register(sarg1, guysbuf[ID].member * 10000); \
36875 }
36876
36877 #define GET_NPCDATA_FUNCTION_VAR_INDEX(member, indexbound) \
36878 { \
36879 int32_t ID = int32_t(ri->d[rINDEX] / 10000);\
36880 int32_t indx = vbound((ri->d[rINDEX2] / 10000), 0, indexbound); \
36881 if(ID < 1 || ID > (MAXGUYS-1)) \
36882 set_register(sarg1, -10000); \
36883 else \
36884 set_register(sarg1, guysbuf[ID].member[indx] * 10000); \
36885 }
36886
36887 #define GET_NPCDATA_FUNCTION_VAR_FLAG(member) \
36888 { \
36889 int32_t ID = int32_t(ri->d[rINDEX] / 10000);\
36890 int32_t flag = int32_t(ri->d[rINDEX2] / 10000);\
36891 if(ID < 1 || ID > (MAXGUYS-1)) \
36892 set_register(sarg1, -10000); \
36893 else \
36894 set_register(sarg1, (guysbuf[ID].member&flag) ? 10000 : 0); \
36895 }
36896
36897 void FFScript::getNPCData_tile(){ GET_NPCDATA_FUNCTION_VAR_INT(tile); } //word
36898 void FFScript::getNPCData_e_height(){ GET_NPCDATA_FUNCTION_VAR_INT(e_height); }
36899 void FFScript::getNPCData_flags(){ GET_NPCDATA_FUNCTION_VAR_INT(flags); } //word
36900 void FFScript::getNPCData_flags2(){ GET_NPCDATA_FUNCTION_VAR_INT(flags2); }
36901 void FFScript::getNPCData_width(){ GET_NPCDATA_FUNCTION_VAR_INT(width); }
36902 void FFScript::getNPCData_height(){ GET_NPCDATA_FUNCTION_VAR_INT(height); }
36903 void FFScript::getNPCData_s_tile(){ GET_NPCDATA_FUNCTION_VAR_INT(s_tile); }
36904 void FFScript::getNPCData_s_width(){ GET_NPCDATA_FUNCTION_VAR_INT(s_width); }
36905 void FFScript::getNPCData_s_height(){ GET_NPCDATA_FUNCTION_VAR_INT(s_height); }
36906 void FFScript::getNPCData_e_tile(){ GET_NPCDATA_FUNCTION_VAR_INT(e_tile); }
36907 void FFScript::getNPCData_e_width(){ GET_NPCDATA_FUNCTION_VAR_INT(e_width); }
36908 void FFScript::getNPCData_hp(){ GET_NPCDATA_FUNCTION_VAR_INT(hp); }
36909 void FFScript::getNPCData_family(){ GET_NPCDATA_FUNCTION_VAR_INT(family); }
36910 void FFScript::getNPCData_cset(){ GET_NPCDATA_FUNCTION_VAR_INT(cset); }
36911 void FFScript::getNPCData_anim(){ GET_NPCDATA_FUNCTION_VAR_INT(anim); }
36912 void FFScript::getNPCData_e_anim(){ GET_NPCDATA_FUNCTION_VAR_INT(e_anim); }
36913 void FFScript::getNPCData_frate(){ GET_NPCDATA_FUNCTION_VAR_INT(frate); }
36914 void FFScript::getNPCData_e_frate(){ GET_NPCDATA_FUNCTION_VAR_INT(e_frate); }
36915 void FFScript::getNPCData_dp(){ GET_NPCDATA_FUNCTION_VAR_INT(dp); }
36916 void FFScript::getNPCData_wdp(){ GET_NPCDATA_FUNCTION_VAR_INT(wdp); }
36917 void FFScript::getNPCData_weapon(){ GET_NPCDATA_FUNCTION_VAR_INT(weapon); }
36918 void FFScript::getNPCData_rate(){ GET_NPCDATA_FUNCTION_VAR_INT(rate); }
36919 void FFScript::getNPCData_hrate(){ GET_NPCDATA_FUNCTION_VAR_INT(hrate); }
36920 void FFScript::getNPCData_step(){ GET_NPCDATA_FUNCTION_VAR_INT(step); }
36921 void FFScript::getNPCData_homing(){ GET_NPCDATA_FUNCTION_VAR_INT(homing); }
36922 void FFScript::getNPCData_grumble(){ GET_NPCDATA_FUNCTION_VAR_INT(grumble); }
36923 void FFScript::getNPCData_item_set(){ GET_NPCDATA_FUNCTION_VAR_INT(item_set); }
36924 void FFScript::getNPCData_bgsfx(){ GET_NPCDATA_FUNCTION_VAR_INT(bgsfx); }
36925 void FFScript::getNPCData_hitsfx(){ GET_NPCDATA_FUNCTION_VAR_INT(hitsfx); }
36926 void FFScript::getNPCData_deadsfx(){ GET_NPCDATA_FUNCTION_VAR_INT(deadsfx); }
36927 void FFScript::getNPCData_xofs(){ GET_NPCDATA_FUNCTION_VAR_INT(xofs); }
36928 void FFScript::getNPCData_yofs(){ GET_NPCDATA_FUNCTION_VAR_INT(yofs); }
36929 void FFScript::getNPCData_zofs(){ GET_NPCDATA_FUNCTION_VAR_INT(zofs); }
36930 void FFScript::getNPCData_hxofs(){ GET_NPCDATA_FUNCTION_VAR_INT(hxofs); }
36931 void FFScript::getNPCData_hyofs(){ GET_NPCDATA_FUNCTION_VAR_INT(hyofs); }
36932 void FFScript::getNPCData_hxsz(){ GET_NPCDATA_FUNCTION_VAR_INT(hxsz); }
36933 void FFScript::getNPCData_hysz(){ GET_NPCDATA_FUNCTION_VAR_INT(hysz); }
36934 void FFScript::getNPCData_hzsz(){ GET_NPCDATA_FUNCTION_VAR_INT(hzsz); }
36935 void FFScript::getNPCData_txsz(){ GET_NPCDATA_FUNCTION_VAR_INT(txsz); }
36936 void FFScript::getNPCData_tysz(){ GET_NPCDATA_FUNCTION_VAR_INT(tysz); }
36937 void FFScript::getNPCData_wpnsprite(){ GET_NPCDATA_FUNCTION_VAR_INT(wpnsprite); }
36938
36939 //NPCData Getters, two inputs, one return, similar to ISSolid
36940
36941 /*
36942
36943 void do_issolid()
36944 {
36945 int32_t x = int32_t(ri->d[rINDEX] / 10000);
36946 int32_t y = int32_t(ri->d[rINDEX2] / 10000);
36947
36948 set_register(sarg1, (_walkflag(x, y, 1) ? 10000 : 0));
36949 }
36950
36951 */
36952
36953
36954
36955
36956
36957
36958 //void FFScript::getNPCData_scriptdefence(){GET_NPCDATA_FUNCTION_VAR_INDEX(scriptdefence)};
36959
36960
36961 void FFScript::getNPCData_defense(){GET_NPCDATA_FUNCTION_VAR_INDEX(defense,int32_t(edefLAST255))};
36962
36963
36964 void FFScript::getNPCData_SIZEflags(){GET_NPCDATA_FUNCTION_VAR_FLAG(SIZEflags);}
36965
36966
36967 void FFScript::getNPCData_misc()
36968 {
36969 int32_t ID = int32_t(ri->d[rINDEX] / 10000); //the enemy ID value
36970 int32_t indx = int32_t(ri->d[rINDEX2] / 10000); //the misc index ID
36971 if ((ID < 1 || ID > 511) || ( indx < 0 || indx > 15 ))
36972 set_register(sarg1, -10000);
36973 switch ( indx )
36974 {
36975 case 0: set_register(sarg1, guysbuf[ID].misc1 * 10000); break;
36976 case 1: set_register(sarg1, guysbuf[ID].misc2 * 10000); break;
36977 case 2: set_register(sarg1, guysbuf[ID].misc3 * 10000); break;
36978 case 3: set_register(sarg1, guysbuf[ID].misc4 * 10000); break;
36979 case 4: set_register(sarg1, guysbuf[ID].misc5 * 10000); break;
36980 case 5: set_register(sarg1, guysbuf[ID].misc6 * 10000); break;
36981 case 6: set_register(sarg1, guysbuf[ID].misc7 * 10000); break;
36982 case 7: set_register(sarg1, guysbuf[ID].misc8 * 10000); break;
36983 case 8: set_register(sarg1, guysbuf[ID].misc9 * 10000); break;
36984 case 9: set_register(sarg1, guysbuf[ID].misc10 * 10000); break;
36985 case 10: set_register(sarg1, guysbuf[ID].misc11 * 10000); break;
36986 case 11: set_register(sarg1, guysbuf[ID].misc12 * 10000); break;
36987 case 12: set_register(sarg1, guysbuf[ID].misc13 * 10000); break;
36988 case 13: set_register(sarg1, guysbuf[ID].misc14 * 10000); break;
36989 case 14: set_register(sarg1, guysbuf[ID].misc15 * 10000); break;
36990 default: set_register(sarg1, -10000); break;
36991 }
36992 }
36993
36994 //NPCData Setters, two inputs, no return; similar to void GetDMapIntro(int32_t DMap, int32_t buffer[]);
36995
36996 /*
36997
36998 void do_getdmapintro(const bool v)
36999 {
37000 int32_t ID = SH::get_arg(sarg1, v) / 10000;
37001 int32_t arrayptr = get_register(sarg2) / 10000;
37002
37003 if(BC::checkDMapID(ID, "Game->GetDMapIntro") != SH::_NoError)
37004 return;
37005
37006 if(ArrayH::setArray(arrayptr, string(DMaps[ID].intro)) == SH::_Overflow)
37007 Z_scripterrlog("Array supplied to 'Game->GetDMapIntro' not large enough\n");
37008 }
37009
37010 */
37011
37012 //NPCData Setter Macros
37013
37014 //Variables for spritedata sp->member
37015
37016
37017
37018 //Functions for NPCData->
37019
37020 #define SET_NPCDATA_FUNCTION_VAR_INT(member, bound) \
37021 { \
37022 int32_t ID = get_register(sarg1) / 10000; \
37023 int32_t val = get_register(sarg2) / 10000; \
37024 if(ID < 1 || ID > (MAXGUYS-1)) \
37025 set_register(sarg1, -10000); \
37026 else \
37027 guysbuf[ID].member = vbound(val,0,bound); \
37028 }
37029
37030
37031
37032 #define SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(member) \
37033 { \
37034 int32_t ID = get_register(sarg1) / 10000; \
37035 int32_t val = get_register(sarg2) / 10000; \
37036 if(ID < 1 || ID > (MAXGUYS-1)) \
37037 set_register(sarg1, -10000); \
37038 else \
37039 guysbuf[ID].member = val; \
37040 }
37041
37042
37043 //SET_NPC_VAR_INDEX(member,value)
37044 #define SET_NPCDATA_FUNCTION_VAR_INDEX(member, val, bound, indexbound) \
37045 { \
37046 int32_t ID = (ri->d[rINDEX]/10000); \
37047 int32_t indx = vbound((ri->d[rINDEX2]/10000),0,indexbound); \
37048 if(ID < 1 || ID > (MAXGUYS-1)) \
37049 return; \
37050 else \
37051 guysbuf[ID].member[indx] = vbound(val,0,bound); \
37052 }
37053
37054 //Special case for flags, three inputs one return
37055 #define SET_NPCDATA_FUNCTION_VAR_FLAG(member, val) \
37056 { \
37057 int32_t ID = (ri->d[rINDEX]/10000); \
37058 int32_t flag = (ri->d[rINDEX2]/10000); \
37059 if(ID < 1 || ID > (MAXGUYS-1)) \
37060 return; \
37061 else \
37062 { \
37063 if ( val != 0 ) guysbuf[ID].member|=flag; \
37064 else guysbuf[ID].member|= ~flag; \
37065 }\
37066 }
37067
37068 void FFScript::setNPCData_flags(){SET_NPCDATA_FUNCTION_VAR_INT(flags,ZS_DWORD);} //word
37069 void FFScript::setNPCData_flags2(){SET_NPCDATA_FUNCTION_VAR_INT(flags2,ZS_DWORD);}
37070 void FFScript::setNPCData_width(){SET_NPCDATA_FUNCTION_VAR_INT(width,ZS_BYTE);}
37071 void FFScript::setNPCData_tile(){SET_NPCDATA_FUNCTION_VAR_INT(tile,ZS_WORD);}
37072 void FFScript::setNPCData_e_height(){SET_NPCDATA_FUNCTION_VAR_INT(e_height,ZS_BYTE);}
37073 void FFScript::setNPCData_height(){SET_NPCDATA_FUNCTION_VAR_INT(height,ZS_BYTE);}
37074 void FFScript::setNPCData_s_tile(){SET_NPCDATA_FUNCTION_VAR_INT(s_tile,ZS_WORD);}
37075 void FFScript::setNPCData_s_width(){SET_NPCDATA_FUNCTION_VAR_INT(s_width,ZS_BYTE);}
37076 void FFScript::setNPCData_s_height(){SET_NPCDATA_FUNCTION_VAR_INT(s_height,ZS_BYTE);}
37077 void FFScript::setNPCData_e_tile(){SET_NPCDATA_FUNCTION_VAR_INT(e_tile,ZS_WORD);}
37078 void FFScript::setNPCData_e_width(){SET_NPCDATA_FUNCTION_VAR_INT(e_width,ZS_BYTE);}
37079 void FFScript::setNPCData_hp(){SET_NPCDATA_FUNCTION_VAR_INT(hp,ZS_SHORT);}
37080 void FFScript::setNPCData_family(){SET_NPCDATA_FUNCTION_VAR_INT(family,ZS_SHORT);}
37081 void FFScript::setNPCData_cset(){SET_NPCDATA_FUNCTION_VAR_INT(cset,ZS_SHORT);}
37082 void FFScript::setNPCData_anim(){SET_NPCDATA_FUNCTION_VAR_INT(anim,ZS_SHORT);}
37083 void FFScript::setNPCData_e_anim(){SET_NPCDATA_FUNCTION_VAR_INT(e_anim,ZS_SHORT);}
37084 void FFScript::setNPCData_frate(){SET_NPCDATA_FUNCTION_VAR_INT(frate,ZS_SHORT);}
37085 void FFScript::setNPCData_e_frate(){SET_NPCDATA_FUNCTION_VAR_INT(e_frate,ZS_SHORT);}
37086 void FFScript::setNPCData_dp(){SET_NPCDATA_FUNCTION_VAR_INT(dp,ZS_SHORT);}
37087 void FFScript::setNPCData_wdp(){SET_NPCDATA_FUNCTION_VAR_INT(wdp,ZS_SHORT);}
37088 void FFScript::setNPCData_weapon(){SET_NPCDATA_FUNCTION_VAR_INT(weapon,ZS_SHORT);}
37089 void FFScript::setNPCData_rate(){SET_NPCDATA_FUNCTION_VAR_INT(rate,ZS_SHORT);}
37090 void FFScript::setNPCData_hrate(){SET_NPCDATA_FUNCTION_VAR_INT(hrate,ZS_SHORT);}
37091 void FFScript::setNPCData_step(){SET_NPCDATA_FUNCTION_VAR_INT(step,ZS_SHORT);}
37092 void FFScript::setNPCData_homing(){SET_NPCDATA_FUNCTION_VAR_INT(homing,ZS_SHORT);}
37093 void FFScript::setNPCData_grumble(){SET_NPCDATA_FUNCTION_VAR_INT(grumble,ZS_SHORT);}
37094 void FFScript::setNPCData_item_set(){SET_NPCDATA_FUNCTION_VAR_INT(item_set,ZS_SHORT);}
37095 void FFScript::setNPCData_bgsfx(){SET_NPCDATA_FUNCTION_VAR_INT(bgsfx,ZS_SHORT);}
37096 void FFScript::setNPCData_hitsfx(){SET_NPCDATA_FUNCTION_VAR_INT(hitsfx,ZS_BYTE);}
37097 void FFScript::setNPCData_deadsfx(){SET_NPCDATA_FUNCTION_VAR_INT(deadsfx,ZS_BYTE);}
37098 void FFScript::setNPCData_xofs(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(xofs);}
37099 void FFScript::setNPCData_yofs(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(yofs);}
37100 void FFScript::setNPCData_zofs(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(zofs);}
37101 void FFScript::setNPCData_hxofs(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(hxofs);}
37102 void FFScript::setNPCData_hyofs(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(hyofs);}
37103 void FFScript::setNPCData_hxsz(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(hxsz);}
37104 void FFScript::setNPCData_hysz(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(hysz);}
37105 void FFScript::setNPCData_hzsz(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(hzsz);}
37106 void FFScript::setNPCData_txsz(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(txsz);}
37107 void FFScript::setNPCData_tysz(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(tysz);}
37108 void FFScript::setNPCData_wpnsprite(){SET_NPCDATA_FUNCTION_VAR_INT(wpnsprite,511);}
37109
37110 //NPCData Setters, three inputs, no return. works as SetDMapScreenD function
37111
37112
37113
37114
37115
37116
37117
37118 //void FFScript::setNPCData_scriptdefence(){SET_NPCDATA_FUNCTION_VAR_INDEX(scriptdefence);}
37119 void FFScript::setNPCData_defense(int32_t v){SET_NPCDATA_FUNCTION_VAR_INDEX(defense,v, ZS_INT, int32_t(edefLAST255) );}
37120 void FFScript::setNPCData_SIZEflags(int32_t v){SET_NPCDATA_FUNCTION_VAR_FLAG(SIZEflags,v);}
37121 void FFScript::setNPCData_misc(int32_t val)
37122 {
37123 int32_t ID = int32_t(ri->d[rINDEX] / 10000); //the enemy ID value
37124 int32_t indx = int32_t(ri->d[rINDEX2] / 10000); //the misc index ID
37125 if ((ID < 1 || ID > 511) || ( indx < 0 || indx > 15 )) return;
37126 switch ( indx )
37127 {
37128 case 0: guysbuf[ID].misc1 = val; break;
37129 case 1: guysbuf[ID].misc2 = val; break;
37130 case 2: guysbuf[ID].misc3 = val; break;
37131 case 3: guysbuf[ID].misc4 = val; break;
37132 case 4: guysbuf[ID].misc5 = val; break;
37133 case 5: guysbuf[ID].misc6 = val; break;
37134 case 6: guysbuf[ID].misc7 = val; break;
37135 case 7: guysbuf[ID].misc8 = val; break;
37136 case 8: guysbuf[ID].misc9 = val; break;
37137 case 9: guysbuf[ID].misc10 = val; break;
37138 case 10: guysbuf[ID].misc11 = val; break;
37139 case 11: guysbuf[ID].misc12 = val; break;
37140 case 12: guysbuf[ID].misc13 = val; break;
37141 case 13: guysbuf[ID].misc14 = val; break;
37142 case 14: guysbuf[ID].misc15 = val; break;
37143 default: break;
37144 }
37145
37146 };
37147
37148 //ComboData
37149
37150 //Macros
37151
37152 //Are these right? newcombo is *combo_class_buf and the others are *combobuf
37153
37154 //Getters for ComboData 'Type' submembers.
37155 #define GET_COMBODATA_TYPE_INT(member) \
37156 { \
37157 int32_t ID = vbound((get_register(sarg2) / 10000),0,MAXCOMBOS);\
37158 set_register(sarg1, combo_class_buf[combobuf[ID].type].member * 10000); \
37159 }
37160
37161 //this may need additional macros.
37162 //for combo_class_buf[ID].member ?
37163 //I'm not sure which it needs to be at present.
37164
37165 #define GET_COMBODATA_TYPE_INDEX(member, bound) \
37166 { \
37167 int32_t ID = int32_t(vbound((ri->d[rINDEX] / 10000),0,MAXCOMBOS));\
37168 int32_t indx = int32_t(vbound((ri->d[rINDEX2] / 10000), 0, bound));\
37169 set_register(sarg1, combo_class_buf[combobuf[ID].type].member[indx] * 10000); \
37170 }
37171
37172 #define GET_COMBODATA_TYPE_FLAG(member) \
37173 { \
37174 int32_t ID = int32_t(vbound(ri->d[rINDEX] / 10000),0,MAXCOMBOS);\
37175 int32_t flag = int32_t(ri->d[rINDEX2] / 10000);\
37176 set_register(sarg1, (combo_class_buf[combobuf[ID].type].member&flag) ? 10000 : 0); \
37177 }
37178
37179
37180
37181 //Getters for ComboData main members.
37182 #define GET_COMBODATA_VAR_INT(member) \
37183 { \
37184 int32_t ID = vbound( (get_register(sarg2) / 10000), 0, MAXCOMBOS);\
37185 set_register(sarg1, combobuf[ID].member * 10000); \
37186 }
37187
37188 #define GET_COMBODATA_VAR_INDEX(member, bound) \
37189 { \
37190 int32_t ID = int32_t( vbound( (ri->d[rINDEX] / 10000),0,MAXCOMBOS) );\
37191 int32_t indx = int32_t ( vbound( (ri->d[rINDEX2] / 10000),0,bound) );\
37192 set_register(sarg1, combobuf[ID].member[indx] * 10000); \
37193 }
37194
37195 #define GET_COMBODATA_VAR_FLAG(member) \
37196 { \
37197 int32_t ID = int32_t( vbound( ( ri->d[rINDEX] / 10000),0,MAXCOMBOS) );\
37198 int32_t flag = int32_t(ri->d[rINDEX2] / 10000);\
37199 set_register(sarg1, (combobuf[ID].member&flag) ? 10000 : 0); \
37200 }
37201
37202
37203
37204 //ComboData Setter Macros
37205
37206 //Setters for ComboData 'type' submembers.
37207 #define SET_COMBODATA_TYPE_INT(member, bound) \
37208 { \
37209 int32_t ID = get_register(sarg1) / 10000; \
37210 int32_t val = vbound( (get_register(sarg2) / 10000), 0, bound); \
37211 if(ID < 1 || ID > 511) \
37212 set_register(sarg1, -10000); \
37213 else \
37214 combo_class_buf[combobuf[ID].type].member = val; \
37215 }
37216
37217 #define SET_COMBODATA_TYPE_INDEX(member, val, bound, indexbound) \
37218 { \
37219 int32_t ID = vbound((ri->d[rINDEX]/10000),0,MAXCOMBOS); \
37220 int32_t indx = vbound((ri->d[rINDEX2]/10000),0,indexbound); \
37221 combo_class_buf[combobuf[ID].type].member[indx] = vbound(val,0,bound); \
37222 }
37223
37224 #define SET_COMBODATA_TYPE_FLAG(member, val, bound) \
37225 { \
37226 int32_t ID = vbound((ri->d[rINDEX]/10000),0,MAXCOMBOS); \
37227 int32_t flag = (ri->d[rINDEX2]/10000); \
37228 combo_class_buf[combobuf[ID].type].member&flag = ((vbound(val,0,bound))!=0); \
37229 \
37230
37231
37232 //Setters for ComboData main members
37233 #define SET_COMBODATA_VAR_INT(member, bound) \
37234 { \
37235 int32_t ID = vbound( (get_register(sarg1) / 10000), 0, MAXCOMBOS); \
37236 int32_t val = vbound((get_register(sarg2) / 10000),0,bound); \
37237 combobuf[ID].member = val; \
37238 }
37239
37240 //SET_NPC_VAR_INDEX(member,value)
37241 #define SET_COMBODATA_VAR_INDEX(member, val, bound, indexbound) \
37242 { \
37243 int32_t ID = vbound((ri->d[rINDEX]/10000),0,MAXCOMBOS); \
37244 int32_t indx = vbound((ri->d[rINDEX2]/10000),0,indexbound); \
37245 combobuf[ID].member[indx] = vbound(val,0,bound); \
37246 }
37247
37248 //Special case for flags, three inputs one return
37249 #define SET_COMBODATA_VAR_FLAG(member, val, bound) \
37250 { \
37251 int32_t ID = vbound((ri->d[rINDEX]/10000),0,MAXCOMBOS); \
37252 int32_t flag = (ri->d[rINDEX2]/10000); \
37253 else \
37254 { \
37255 combobuf[ID].member&flag = ((bvound(val,0,bound))!=0); \
37256 }\
37257 }
37258
37259 //Getters
37260
37261 //one input, one return
37262 void FFScript::getComboData_block_enemies(){ GET_COMBODATA_TYPE_INT(block_enemies); } //byte a
37263 void FFScript::getComboData_block_hole(){ GET_COMBODATA_TYPE_INT(block_hole); } //byte b
37264 void FFScript::getComboData_block_trigger(){ GET_COMBODATA_TYPE_INT(block_trigger); } //byte c
37265 void FFScript::getComboData_conveyor_x_speed(){ GET_COMBODATA_TYPE_INT(conveyor_x_speed); } //int16_t e
37266 void FFScript::getComboData_conveyor_y_speed(){ GET_COMBODATA_TYPE_INT(conveyor_y_speed); } //int16_t f
37267 void FFScript::getComboData_create_enemy(){ GET_COMBODATA_TYPE_INT(create_enemy); } //word g
37268 void FFScript::getComboData_create_enemy_when(){ GET_COMBODATA_TYPE_INT(create_enemy_when); } //byte h
37269 void FFScript::getComboData_create_enemy_change(){ GET_COMBODATA_TYPE_INT(create_enemy_change); } //int32_t i
37270 void FFScript::getComboData_directional_change_type(){ GET_COMBODATA_TYPE_INT(directional_change_type); } //byte j
37271 void FFScript::getComboData_distance_change_tiles(){ GET_COMBODATA_TYPE_INT(distance_change_tiles); } //int32_t k
37272 void FFScript::getComboData_dive_item(){ GET_COMBODATA_TYPE_INT(dive_item); } //int16_t l
37273 void FFScript::getComboData_dock(){ GET_COMBODATA_TYPE_INT(dock); } //byte m
37274 void FFScript::getComboData_fairy(){ GET_COMBODATA_TYPE_INT(fairy); } //byte n
37275 void FFScript::getComboData_ff_combo_attr_change(){ GET_COMBODATA_TYPE_INT(ff_combo_attr_change); } //byte o
37276 void FFScript::getComboData_foot_decorations_tile(){ GET_COMBODATA_TYPE_INT(foot_decorations_tile); } //int32_t p
37277 void FFScript::getComboData_foot_decorations_type(){ GET_COMBODATA_TYPE_INT(foot_decorations_type); } //byte q
37278 void FFScript::getComboData_hookshot_grab_point(){ GET_COMBODATA_TYPE_INT(hookshot_grab_point); } //byte r
37279 void FFScript::getComboData_ladder_pass(){ GET_COMBODATA_TYPE_INT(ladder_pass); } //byte s
37280 void FFScript::getComboData_lock_block_type(){ GET_COMBODATA_TYPE_INT(lock_block_type); } //byte t
37281 void FFScript::getComboData_lock_block_change(){ GET_COMBODATA_TYPE_INT(lock_block_change); } //int32_t u
37282 void FFScript::getComboData_magic_mirror_type(){ GET_COMBODATA_TYPE_INT(magic_mirror_type); } //byte v
37283 void FFScript::getComboData_modify_hp_amount(){ GET_COMBODATA_TYPE_INT(modify_hp_amount); } //int16_t w
37284 void FFScript::getComboData_modify_hp_delay(){ GET_COMBODATA_TYPE_INT(modify_hp_delay); } //byte x
37285 void FFScript::getComboData_modify_hp_type(){ GET_COMBODATA_TYPE_INT(modify_hp_type); } //byte y
37286 void FFScript::getComboData_modify_mp_amount(){ GET_COMBODATA_TYPE_INT(modify_mp_amount); } //int16_t z
37287 void FFScript::getComboData_modify_mp_delay(){ GET_COMBODATA_TYPE_INT(modify_mp_delay); } //byte aa
37288 void FFScript::getComboData_modify_mp_type(){ GET_COMBODATA_TYPE_INT(modify_mp_type); } //byte ab
37289 void FFScript::getComboData_no_push_blocks(){ GET_COMBODATA_TYPE_INT(no_push_blocks); } //byte ac
37290 void FFScript::getComboData_overhead(){ GET_COMBODATA_TYPE_INT(overhead); } //byte ad
37291 void FFScript::getComboData_place_enemy(){ GET_COMBODATA_TYPE_INT(place_enemy); } //byte ae
37292 void FFScript::getComboData_push_direction(){ GET_COMBODATA_TYPE_INT(push_direction); } //byte af
37293 void FFScript::getComboData_push_weight(){ GET_COMBODATA_TYPE_INT(push_weight); } //byte ag heavy or not
37294 void FFScript::getComboData_push_wait(){ GET_COMBODATA_TYPE_INT(push_wait); } //byte ah
37295 void FFScript::getComboData_pushed(){ GET_COMBODATA_TYPE_INT(pushed); } //byte ai
37296 void FFScript::getComboData_raft(){ GET_COMBODATA_TYPE_INT(raft); } //byte aj
37297 void FFScript::getComboData_reset_room(){ GET_COMBODATA_TYPE_INT(reset_room); } //byte ak
37298 void FFScript::getComboData_save_point_type(){ GET_COMBODATA_TYPE_INT(save_point_type); } //byte al
37299 void FFScript::getComboData_screen_freeze_type(){ GET_COMBODATA_TYPE_INT(screen_freeze_type); } //byte am
37300
37301 void FFScript::getComboData_secret_combo(){ GET_COMBODATA_TYPE_INT(secret_combo); } //byte an
37302 void FFScript::getComboData_singular(){ GET_COMBODATA_TYPE_INT(singular); } //byte ao
37303 void FFScript::getComboData_slow_movement(){ GET_COMBODATA_TYPE_INT(slow_movement); } //byte ap
37304 void FFScript::getComboData_statue_type(){ GET_COMBODATA_TYPE_INT(statue_type); } //byte aq
37305 void FFScript::getComboData_step_type(){ GET_COMBODATA_TYPE_INT(step_type); } //byte ar
37306 void FFScript::getComboData_step_change_to(){ GET_COMBODATA_TYPE_INT(step_change_to); } //int32_t as
37307 void FFScript::getComboData_strike_remnants(){ GET_COMBODATA_TYPE_INT(strike_remnants); } //int32_t au
37308 void FFScript::getComboData_strike_remnants_type(){ GET_COMBODATA_TYPE_INT(strike_remnants_type); } //byte av
37309 void FFScript::getComboData_strike_change(){ GET_COMBODATA_TYPE_INT(strike_change); } //int32_t aw
37310 void FFScript::getComboData_strike_item(){ GET_COMBODATA_TYPE_INT(strike_item); } //int16_t ax
37311 void FFScript::getComboData_touch_item(){ GET_COMBODATA_TYPE_INT(touch_item); } //int16_t ay
37312 void FFScript::getComboData_touch_stairs(){ GET_COMBODATA_TYPE_INT(touch_stairs); } //byte az
37313 void FFScript::getComboData_trigger_type(){ GET_COMBODATA_TYPE_INT(trigger_type); } //byte ba
37314 void FFScript::getComboData_trigger_sensitive(){ GET_COMBODATA_TYPE_INT(trigger_sensitive); } //byte bb
37315 void FFScript::getComboData_warp_type(){ GET_COMBODATA_TYPE_INT(warp_type); } //byte bc
37316 void FFScript::getComboData_warp_sensitive(){ GET_COMBODATA_TYPE_INT(warp_sensitive); } //byte bd
37317 void FFScript::getComboData_warp_direct(){ GET_COMBODATA_TYPE_INT(warp_direct); } //byte be
37318 void FFScript::getComboData_warp_location(){ GET_COMBODATA_TYPE_INT(warp_location); } //byte bf
37319 void FFScript::getComboData_water(){ GET_COMBODATA_TYPE_INT(water); } //byte bg
37320 void FFScript::getComboData_whistle(){ GET_COMBODATA_TYPE_INT(whistle); } //byte bh
37321 void FFScript::getComboData_win_game(){ GET_COMBODATA_TYPE_INT(win_game); } //byte bi
37322 void FFScript::getComboData_block_weapon_lvl(){ GET_COMBODATA_TYPE_INT(block_weapon_lvl); } //byte bj - max level of weapon to block
37323
37324 void FFScript::getComboData_tile(){ GET_COMBODATA_VAR_INT(tile); } //newcombo, word
37325 void FFScript::getComboData_flip(){ GET_COMBODATA_VAR_INT(flip); } //newcombo byte
37326
37327 void FFScript::getComboData_walk(){ GET_COMBODATA_VAR_INT(walk); } //newcombo byte
37328 void FFScript::getComboData_type(){ GET_COMBODATA_VAR_INT(type); } //newcombo byte
37329 void FFScript::getComboData_csets(){ GET_COMBODATA_VAR_INT(csets); } //newcombo byte
37330 void FFScript::getComboData_frames(){ GET_COMBODATA_VAR_INT(frames); } //newcombo byte
37331 void FFScript::getComboData_speed(){ GET_COMBODATA_VAR_INT(speed); } //newcombo byte
37332 void FFScript::getComboData_nextcombo(){ GET_COMBODATA_VAR_INT(nextcombo); } //newcombo word
37333 void FFScript::getComboData_nextcset(){ GET_COMBODATA_VAR_INT(nextcset); } //newcombo byte
37334 void FFScript::getComboData_flag(){ GET_COMBODATA_VAR_INT(flag); } //newcombo byte
37335 void FFScript::getComboData_skipanim(){ GET_COMBODATA_VAR_INT(skipanim); } //newcombo byte
37336 void FFScript::getComboData_nexttimer(){ GET_COMBODATA_VAR_INT(nexttimer); } //newcombo word
37337 void FFScript::getComboData_skipanimy(){ GET_COMBODATA_VAR_INT(skipanimy); } //newcombo byte
37338 void FFScript::getComboData_animflags(){ GET_COMBODATA_VAR_INT(animflags); } //newcombo byte
37339
37340
37341 //two inputs, one return
37342 void FFScript::getComboData_block_weapon(){ GET_COMBODATA_TYPE_INDEX(block_weapon,32); } //byte array[32] d (ID of LWeapon)
37343 void FFScript::getComboData_expansion(){ GET_COMBODATA_VAR_INDEX(expansion,6); } //newcombo byte, arr[6]
37344 void FFScript::getComboData_strike_weapons(){ GET_COMBODATA_TYPE_INDEX(strike_weapons,32); } //byte at, arr[32]
37345
37346 //Setters, two inputs no returns
37347
37348 void FFScript::setComboData_block_enemies(){ SET_COMBODATA_TYPE_INT(block_enemies,ZS_BYTE); } //byte a
37349 void FFScript::setComboData_block_hole(){ SET_COMBODATA_TYPE_INT(block_hole,ZS_BYTE); } //byte b
37350 void FFScript::setComboData_block_trigger(){ SET_COMBODATA_TYPE_INT(block_trigger,ZS_BYTE); } //byte c
37351 void FFScript::setComboData_conveyor_x_speed(){ SET_COMBODATA_TYPE_INT(conveyor_x_speed,ZS_SHORT); } //int16_t e
37352 void FFScript::setComboData_conveyor_y_speed(){ SET_COMBODATA_TYPE_INT(conveyor_y_speed,ZS_SHORT); } //int16_t f
37353 void FFScript::setComboData_create_enemy(){ SET_COMBODATA_TYPE_INT(create_enemy,ZS_WORD); } //word g
37354 void FFScript::setComboData_create_enemy_when(){ SET_COMBODATA_TYPE_INT(create_enemy_when,ZS_BYTE); } //byte h
37355 void FFScript::setComboData_create_enemy_change(){ SET_COMBODATA_TYPE_INT(create_enemy_change,ZS_LONG); } //int32_t i
37356 void FFScript::setComboData_directional_change_type(){ SET_COMBODATA_TYPE_INT(directional_change_type,ZS_BYTE); } //byte j
37357 void FFScript::setComboData_distance_change_tiles(){ SET_COMBODATA_TYPE_INT(distance_change_tiles,ZS_LONG); } //int32_t k
37358 void FFScript::setComboData_dive_item(){ SET_COMBODATA_TYPE_INT(dive_item,ZS_SHORT); } //int16_t l
37359 void FFScript::setComboData_dock(){ SET_COMBODATA_TYPE_INT(dock,ZS_BYTE); } //byte m
37360 void FFScript::setComboData_fairy(){ SET_COMBODATA_TYPE_INT(fairy,ZS_BYTE); } //byte n
37361 void FFScript::setComboData_ff_combo_attr_change(){ SET_COMBODATA_TYPE_INT(ff_combo_attr_change,ZS_BYTE); } //byte o
37362 void FFScript::setComboData_foot_decorations_tile(){ SET_COMBODATA_TYPE_INT(foot_decorations_tile,ZS_LONG); } //int32_t p
37363 void FFScript::setComboData_foot_decorations_type(){ SET_COMBODATA_TYPE_INT(foot_decorations_type,ZS_BYTE); } //byte q
37364 void FFScript::setComboData_hookshot_grab_point(){ SET_COMBODATA_TYPE_INT(hookshot_grab_point,ZS_BYTE); } //byte r
37365 void FFScript::setComboData_ladder_pass(){ SET_COMBODATA_TYPE_INT(ladder_pass,ZS_BYTE); } //byte s
37366 void FFScript::setComboData_lock_block_type(){ SET_COMBODATA_TYPE_INT(lock_block_type,ZS_BYTE); } //byte t
37367 void FFScript::setComboData_lock_block_change(){ SET_COMBODATA_TYPE_INT(lock_block_change,ZS_LONG); } //int32_t u
37368 void FFScript::setComboData_magic_mirror_type(){ SET_COMBODATA_TYPE_INT(magic_mirror_type,ZS_BYTE); } //byte v
37369 void FFScript::setComboData_modify_hp_amount(){ SET_COMBODATA_TYPE_INT(modify_hp_amount,ZS_SHORT); } //int16_t w
37370 void FFScript::setComboData_modify_hp_delay(){ SET_COMBODATA_TYPE_INT(modify_hp_delay,ZS_BYTE); } //byte x
37371 void FFScript::setComboData_modify_hp_type(){ SET_COMBODATA_TYPE_INT(modify_hp_type,ZS_BYTE); } //byte y
37372 void FFScript::setComboData_modify_mp_amount(){ SET_COMBODATA_TYPE_INT(modify_mp_amount,ZS_SHORT); } //int16_t z
37373 void FFScript::setComboData_modify_mp_delay(){ SET_COMBODATA_TYPE_INT(modify_mp_delay,ZS_BYTE); } //byte aa
37374 void FFScript::setComboData_modify_mp_type(){ SET_COMBODATA_TYPE_INT(modify_mp_type,ZS_BYTE); } //byte ab
37375 void FFScript::setComboData_no_push_blocks(){ SET_COMBODATA_TYPE_INT(no_push_blocks,ZS_BYTE); } //byte ac
37376 void FFScript::setComboData_overhead(){ SET_COMBODATA_TYPE_INT(overhead,ZS_BYTE); } //byte ad
37377 void FFScript::setComboData_place_enemy(){ SET_COMBODATA_TYPE_INT(place_enemy,ZS_BYTE); } //byte ae
37378 void FFScript::setComboData_push_direction(){ SET_COMBODATA_TYPE_INT(push_direction,ZS_BYTE); } //byte af
37379 void FFScript::setComboData_push_weight(){ SET_COMBODATA_TYPE_INT(push_weight,ZS_BYTE); } //byte ag heavy or not
37380 void FFScript::setComboData_push_wait(){ SET_COMBODATA_TYPE_INT(push_wait,ZS_BYTE); } //byte ah
37381 void FFScript::setComboData_pushed(){ SET_COMBODATA_TYPE_INT(pushed,ZS_BYTE); } //byte ai
37382 void FFScript::setComboData_raft(){ SET_COMBODATA_TYPE_INT(raft,ZS_BYTE); } //byte aj
37383 void FFScript::setComboData_reset_room(){ SET_COMBODATA_TYPE_INT(reset_room,ZS_BYTE); } //byte ak
37384 void FFScript::setComboData_save_point_type(){ SET_COMBODATA_TYPE_INT(save_point_type,ZS_BYTE); } //byte al
37385 void FFScript::setComboData_screen_freeze_type(){ SET_COMBODATA_TYPE_INT(screen_freeze_type,ZS_BYTE); } //byte am
37386
37387 void FFScript::setComboData_secret_combo(){ SET_COMBODATA_TYPE_INT(secret_combo,ZS_BYTE); } //byte an
37388 void FFScript::setComboData_singular(){ SET_COMBODATA_TYPE_INT(singular,ZS_BYTE); } //byte ao
37389 void FFScript::setComboData_slow_movement(){ SET_COMBODATA_TYPE_INT(slow_movement,ZS_BYTE); } //byte ap
37390 void FFScript::setComboData_statue_type(){ SET_COMBODATA_TYPE_INT(statue_type,ZS_BYTE); } //byte aq
37391 void FFScript::setComboData_step_type(){ SET_COMBODATA_TYPE_INT(step_type,ZS_BYTE); } //byte ar
37392 void FFScript::setComboData_step_change_to(){ SET_COMBODATA_TYPE_INT(step_change_to,ZS_LONG); } //int32_t as
37393
37394 void FFScript::setComboData_strike_remnants(){ SET_COMBODATA_TYPE_INT(strike_remnants,ZS_LONG); } //int32_t au
37395 void FFScript::setComboData_strike_remnants_type(){ SET_COMBODATA_TYPE_INT(strike_remnants_type,ZS_BYTE); } //byte av
37396 void FFScript::setComboData_strike_change(){ SET_COMBODATA_TYPE_INT(strike_change,ZS_LONG); } //int32_t aw
37397 void FFScript::setComboData_strike_item(){ SET_COMBODATA_TYPE_INT(strike_item,ZS_SHORT); } //int16_t ax
37398 void FFScript::setComboData_touch_item(){ SET_COMBODATA_TYPE_INT(touch_item,ZS_SHORT); } //int16_t ay
37399 void FFScript::setComboData_touch_stairs(){ SET_COMBODATA_TYPE_INT(touch_stairs,ZS_BYTE); } //byte az
37400 void FFScript::setComboData_trigger_type(){ SET_COMBODATA_TYPE_INT(trigger_type,ZS_BYTE); } //byte ba
37401 void FFScript::setComboData_trigger_sensitive(){ SET_COMBODATA_TYPE_INT(trigger_sensitive,ZS_BYTE); } //byte bb
37402 void FFScript::setComboData_warp_type(){ SET_COMBODATA_TYPE_INT(warp_type,ZS_BYTE); } //byte bc
37403 void FFScript::setComboData_warp_sensitive(){ SET_COMBODATA_TYPE_INT(warp_sensitive,ZS_BYTE); } //byte bd
37404 void FFScript::setComboData_warp_direct(){ SET_COMBODATA_TYPE_INT(warp_direct,ZS_BYTE); } //byte be
37405 void FFScript::setComboData_warp_location(){ SET_COMBODATA_TYPE_INT(warp_location,ZS_BYTE); } //byte bf
37406 void FFScript::setComboData_water(){ SET_COMBODATA_TYPE_INT(water,ZS_BYTE); } //byte bg
37407 void FFScript::setComboData_whistle(){ SET_COMBODATA_TYPE_INT(whistle,ZS_BYTE); } //byte bh
37408 void FFScript::setComboData_win_game(){ SET_COMBODATA_TYPE_INT(win_game,ZS_BYTE); } //byte bi
37409 void FFScript::setComboData_block_weapon_lvl(){ SET_COMBODATA_TYPE_INT(block_weapon_lvl,ZS_BYTE); } //byte bj - max level of weapon to block
37410
37411 //combobuf
37412 void FFScript::setComboData_tile(){ SET_COMBODATA_VAR_INT(tile,ZS_WORD); } //newcombo, word
37413 void FFScript::setComboData_flip(){ SET_COMBODATA_VAR_INT(flip,ZS_BYTE); } //newcombo byte
37414
37415 void FFScript::setComboData_walk(){ SET_COMBODATA_VAR_INT(walk,ZS_BYTE); } //newcombo byte
37416 void FFScript::setComboData_type(){ SET_COMBODATA_VAR_INT(type,ZS_BYTE); } //newcombo byte
37417 void FFScript::setComboData_csets(){ SET_COMBODATA_VAR_INT(csets,ZS_BYTE); } //newcombo byte
37418 void FFScript::setComboData_frames(){ SET_COMBODATA_VAR_INT(frames,ZS_BYTE); } //newcombo byte
37419 void FFScript::setComboData_speed(){ SET_COMBODATA_VAR_INT(speed,ZS_BYTE); } //newcombo byte
37420 void FFScript::setComboData_nextcombo(){ SET_COMBODATA_VAR_INT(nextcombo,ZS_WORD); } //newcombo word
37421 void FFScript::setComboData_nextcset(){ SET_COMBODATA_VAR_INT(nextcset,ZS_BYTE); } //newcombo byte
37422 void FFScript::setComboData_flag(){ SET_COMBODATA_VAR_INT(flag,ZS_BYTE); } //newcombo byte
37423 void FFScript::setComboData_skipanim(){ SET_COMBODATA_VAR_INT(skipanim,ZS_BYTE); } //newcombo byte
37424 void FFScript::setComboData_nexttimer(){ SET_COMBODATA_VAR_INT(nexttimer,ZS_WORD); } //newcombo word
37425 void FFScript::setComboData_skipanimy(){ SET_COMBODATA_VAR_INT(skipanimy,ZS_BYTE); } //newcombo byte
37426 void FFScript::setComboData_animflags(){ SET_COMBODATA_VAR_INT(animflags,ZS_BYTE); } //newcombo byte
37427
37428 //three inputs, no returns
37429 void FFScript::setComboData_block_weapon(int32_t v){ SET_COMBODATA_TYPE_INDEX(block_weapon,v,ZS_BYTE,32); } //byte array[32] d (ID of LWeapon)
37430 void FFScript::setComboData_strike_weapons(int32_t v){ SET_COMBODATA_TYPE_INDEX(strike_weapons,v,ZS_BYTE,32); } //byte at, arr[32]
37431 void FFScript::setComboData_expansion(int32_t v){ SET_COMBODATA_VAR_INDEX(expansion,v,ZS_BYTE,6); } //newcombo byte, arr[6]
37432
37433 //SpriteData Macros
37434 #define GET_SPRITEDATA_TYPE_INT(member) \
37435 { \
37436 int32_t ID = vbound((get_register(sarg2) / 10000),0,255);\
37437 set_register(sarg1, wpnsbuf[ID].member * 10000); \
37438 }
37439
37440 #define SET_SPRITEDATA_TYPE_INT(member, bound) \
37441 { \
37442 int32_t ID = get_register(sarg1) / 10000; \
37443 int32_t val = vbound( (get_register(sarg2) / 10000), 0, bound); \
37444 if(ID < 1 || ID > 255) \
37445 set_register(sarg1, -10000); \
37446 else \
37447 wpnsbuf[ID].member = val; \
37448 }
37449
37450 #define SET_SPRITEDATA_TYPE_INT_NOBOUND(member) \
37451 { \
37452 int32_t ID = get_register(sarg1) / 10000; \
37453 int32_t val = get_register(sarg2) / 10000; \
37454 if(ID < 1 || ID > 255) \
37455 set_register(sarg1, -10000); \
37456 else \
37457 wpnsbuf[ID].member = val; \
37458 }
37459
37460
37461 void FFScript::getSpriteDataTile(){GET_SPRITEDATA_TYPE_INT(tile);}
37462 void FFScript::getSpriteDataMisc(){GET_SPRITEDATA_TYPE_INT(misc);}
37463 void FFScript::getSpriteDataCSets(){GET_SPRITEDATA_TYPE_INT(csets);}
37464 void FFScript::getSpriteDataFrames(){GET_SPRITEDATA_TYPE_INT(frames);}
37465 void FFScript::getSpriteDataSpeed(){GET_SPRITEDATA_TYPE_INT(speed);}
37466 void FFScript::getSpriteDataType(){GET_SPRITEDATA_TYPE_INT(type);}
37467 //void FFScript::getSpriteDataString();
37468
37469
37470
37471 void FFScript::setSpriteDataTile(){SET_SPRITEDATA_TYPE_INT(tile,ZS_WORD);}
37472 void FFScript::setSpriteDataMisc(){SET_SPRITEDATA_TYPE_INT(misc,ZS_CHAR);}
37473 void FFScript::setSpriteDataCSets(){SET_SPRITEDATA_TYPE_INT(csets,ZS_CHAR);}
37474 void FFScript::setSpriteDataFrames(){SET_SPRITEDATA_TYPE_INT(frames,ZS_CHAR);}
37475 void FFScript::setSpriteDataSpeed(){SET_SPRITEDATA_TYPE_INT(speed,ZS_CHAR);}
37476 void FFScript::setSpriteDataType(){SET_SPRITEDATA_TYPE_INT(type,ZS_CHAR);}
37477 //void FFScript::setSpriteDataString();
37478
37479
37480 void FFScript::do_setMIDI_volume(int32_t m)
37481 {
37482 master_volume(-1,(vbound(m,0,255)));
37483 }
37484 void FFScript::do_setMusic_volume(int32_t m)
37485 {
37486 emusic_volume = vbound(m,0,255);
37487 }
37488 void FFScript::do_setDIGI_volume(int32_t m)
37489 {
37490 master_volume((vbound(m,0,255)),-1);
37491 }
37492 void FFScript::do_setSFX_volume(int32_t m)
37493 {
37494 sfx_volume = m;
37495 }
37496 void FFScript::do_setSFX_pan(int32_t m)
37497 {
37498 pan_style = vbound(m,0,3);
37499 }
37500 int32_t FFScript::do_getMIDI_volume()
37501 {
37502 return ((int32_t)midi_volume);
37503 }
37504 int32_t FFScript::do_getMusic_volume()
37505 {
37506 return ((int32_t)emusic_volume);
37507 }
37508 int32_t FFScript::do_getDIGI_volume()
37509 {
37510 return ((int32_t)digi_volume);
37511 }
37512 int32_t FFScript::do_getSFX_volume()
37513 {
37514 return ((int32_t)sfx_volume);
37515 }
37516 int32_t FFScript::do_getSFX_pan()
37517 {
37518 return ((int32_t)pan_style);
37519 }
37520
37521
37522 //Change Game Over Screen Values
37523 void FFScript::FFSetSaveScreenSetting()
37524 {
37525
37526 int32_t indx = get_register(sarg1) / 10000;
37527 int32_t value = get_register(sarg2) / 10000; //bounded in zelda.cpp
37528 if(indx < 0 || indx > 11)
37529 set_register(sarg1, -10000);
37530 else
37531 SetSaveScreenSetting(indx, value);
37532 }
37533
37534
37535
37536 void FFScript::FFChangeSubscreenText()
37537 {
37538
37539 int32_t index = get_register(sarg1) / 10000;
37540 int32_t arrayptr = get_register(sarg2) / 10000;
37541
37542 if ( index < 0 || index > 3 )
37543 {
37544 al_trace("The index supplied to Game->SetSubscreenText() is invalid. The index specified was: %d /n", index);
37545 return;
37546 }
37547
37548 string filename_str;
37549
37550
37551
37552 ArrayH::getString(arrayptr, filename_str, 73);
37553 ChangeSubscreenText(index,filename_str.c_str());
37554
37555 //newtext[32]='\0';
37556
37557
37558
37559 }
37560
37561 void FFScript::do_typedpointer_typecast(const bool v)
37562 {
37563 int32_t ptr = SH::get_arg(sarg1, v);
37564 set_register(sarg1, ptr);
37565 }
37566
37567 1 void FFScript::SetItemMessagePlayed(int32_t itm)
37568 {
37569 1 game->item_messages_played[itm] = 1;
37570 1 }
37571 1 bool FFScript::GetItemMessagePlayed(int32_t itm)
37572 {
37573 1 return ((game->item_messages_played[itm] ) ? true : false);
37574 }
37575
37576 int32_t FFScript::getQRBit(int32_t rule)
37577 {
37578 return ( get_qr(rule) ? 1 : 0 );
37579 }
37580
37581 12308954 void FFScript::setHeroAction(int32_t a)
37582 {
37583 12308954 FF_hero_action = vbound(a, 0, 255);
37584 12308954 }
37585
37586 52058922 int32_t FFScript::getHeroAction()
37587 {
37588 52058922 int32_t special_action = Hero.getAction2();
37589
2/2
✓ Branch 0 taken 191669 times.
✓ Branch 1 taken 51867253 times.
52058922 if ( special_action != -1 ) return special_action; //spin, dive, charge
37590 51867253 else return FF_hero_action; //everything else
37591 52058922 }
37592 //get_bit
37593
37594 1310547 int32_t FFScript::GetScriptObjectUID(int32_t type)
37595 {
37596 1310547 ++script_UIDs[type];
37597 1310547 return script_UIDs[type];
37598 }
37599
37600 121 void FFScript::SetNegArray()
37601 {
37602 121 can_neg_array = !get_qr(qr_ZS_NO_NEG_ARRAY);
37603 121 }
37604
37605 408 void FFScript::init()
37606 {
37607 408 eventData.clear();
37608 408 countGenScripts();
37609 408 countObjects();
37610
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 408 times.
4488 for ( int32_t q = 0; q < wexLast; q++ ) warpex[q] = 0;
37611 408 print_ZASM = zasm_debugger;
37612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if ( zasm_debugger )
37613 {
37614 ZASMPrint(true);
37615 zasm_break_mode = ZASM_BREAK_HALT;
37616 }
37617
37618 408 temp_no_stepforward = 0;
37619 408 nostepforward = 0;
37620
37621 408 can_neg_array = !get_qr(qr_ZS_NO_NEG_ARRAY);
37622
37623 408 numscriptdraws = 0;
37624 408 max_ff_rules = qr_MAX;
37625 408 coreflags = 0;
37626 408 skip_ending_credits = 0;
37627 408 music_update_cond = 0;
37628 408 music_update_flags = 0;
37629 //quest_format : is this properly initialised?
37630
2/2
✓ Branch 0 taken 27744 times.
✓ Branch 1 taken 408 times.
28152 for ( int32_t q = 0; q < susptLAST; q++ ) { system_suspend[q] = 0; }
37631
2/2
✓ Branch 0 taken 1224 times.
✓ Branch 1 taken 408 times.
1632 for ( int32_t q = 0; q < UID_TYPES; ++q ) { script_UIDs[q] = 0; }
37632 //for ( int32_t q = 0; q < 512; q++ ) FF_rules[q] = 0;
37633 408 FFCore.zasm_break_mode = ZASM_BREAK_NONE;
37634
37635 408 usr_midi_volume = midi_volume;
37636 408 usr_digi_volume = digi_volume;
37637 408 usr_sfx_volume = sfx_volume;
37638 408 usr_music_volume = emusic_volume;
37639
37640 408 usr_panstyle = pan_style;
37641 408 FF_hero_action = 0;
37642 408 enemy_removal_point[spriteremovalY1] = -32767;
37643 408 enemy_removal_point[spriteremovalY2] = 32767;
37644 408 enemy_removal_point[spriteremovalX1] = -32767;
37645 408 enemy_removal_point[spriteremovalX2] = 32767;
37646 408 enemy_removal_point[spriteremovalZ1] = -32767;
37647 408 enemy_removal_point[spriteremovalZ2] = 32767;
37648
37649 //Clear internal arrays for use by <std>, <ghost>, <tango>
37650
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 408 times.
104856 for ( int32_t q = 0; q < 256; ++q )
37651 {
37652 104448 StdArray[q] = 0;
37653 104448 GhostArray[q] = 0;
37654 104448 TangoArray[q] = 0;
37655 104448 }
37656
37657
2/2
✓ Branch 0 taken 1632 times.
✓ Branch 1 taken 408 times.
2040 for ( int32_t q = 0; q < 4; q++ )
37658 {
37659 1632 FF_screenbounds[q] = 0;
37660 1632 FF_screen_dimensions[q] = 0;
37661 1632 FF_subscreen_dimensions[q] = 0;
37662 1632 FF_eweapon_removal_bounds[q] = 0;
37663 1632 FF_lweapon_removal_bounds[q] = 0;
37664 1632 }
37665
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 408 times.
4488 for ( int32_t q = 0; q < FFSCRIPTCLASS_CLOCKS; q++ )
37666 {
37667 4080 FF_clocks[q] = 0;
37668 4080 }
37669
2/2
✓ Branch 0 taken 8160 times.
✓ Branch 1 taken 408 times.
8568 for ( int32_t q = 0; q < SCRIPT_DRAWING_RULES; q++ )
37670 {
37671 8160 ScriptDrawingRules[q] = 0;
37672 8160 }
37673
2/2
✓ Branch 0 taken 2448 times.
✓ Branch 1 taken 408 times.
2856 for ( int32_t q = 0; q < NUM_USER_MIDI_OVERRIDES; q++ )
37674 {
37675 2448 FF_UserMidis[q] = 0;
37676 2448 }
37677 408 subscreen_scroll_speed = 0; //make a define for a default and read quest override! -Z
37678 408 kb_typing_mode = false;
37679 408 initIncludePaths();
37680 408 initRunString();
37681 //clearRunningItemScripts();
37682 408 tempScreens[0] = tmpscr;
37683 408 ScrollingScreens[0] = tmpscr+1;
37684
2/2
✓ Branch 0 taken 2448 times.
✓ Branch 1 taken 408 times.
2856 for(int32_t q = 0; q < 6; ++q)
37685 {
37686 2448 tempScreens[q+1] = tmpscr2+q;
37687 2448 ScrollingScreens[q+1] = tmpscr3+q;
37688 2448 }
37689 408 ScrollingData[SCROLLDATA_DIR] = -1;
37690 408 ScrollingData[SCROLLDATA_NX] = 0;
37691 408 ScrollingData[SCROLLDATA_NY] = 0;
37692 408 ScrollingData[SCROLLDATA_OX] = 0;
37693 408 ScrollingData[SCROLLDATA_OY] = 0;
37694 408 user_rng_init();
37695 408 clear_script_engine_data();
37696
2/2
✓ Branch 0 taken 11015 times.
✓ Branch 1 taken 408 times.
11423 for (auto &it : jitted_scripts)
37697 {
37698 11015 jit_delete_script_handle(it.second);
37699 }
37700 408 jitted_scripts.clear();
37701 408 seen_scripts.clear();
37702 408 script_debug_handles.clear();
37703 408 runtime_script_debug_handle = nullptr;
37704 408 }
37705
37706 void FFScript::shutdown()
37707 {
37708 for (auto &it : jitted_scripts)
37709 {
37710 jit_delete_script_handle(it.second);
37711 }
37712 jitted_scripts.clear();
37713 }
37714
37715
37716 void FFScript::SetFFEngineFlag(int32_t flag, bool state)
37717 {
37718 if ( state ) { coreflags |= flag; }
37719 else coreflags &= ~flag;
37720 }
37721
37722 void FFScript::setSubscreenScrollSpeed(byte n)
37723 {
37724 subscreen_scroll_speed = n;
37725 }
37726
37727 int32_t FFScript::getSubscreenScrollSpeed()
37728 {
37729 return (int32_t)subscreen_scroll_speed;
37730 }
37731
37732 void FFScript::do_greyscale(const bool v)
37733 {
37734 bool on = (SH::get_arg(sarg1, v)) != 0;
37735 setMonochrome(on);
37736 }
37737
37738 void FFScript::do_monochromatic(const bool v)
37739 {
37740 int32_t colour = SH::get_arg(sarg1, v)/10000;
37741 setMonochromatic(colour);
37742 }
37743
37744 void FFScript::gfxmonohue()
37745 {
37746 int32_t _r = SH::read_stack(ri->sp + 3) / 10000;
37747 int32_t _g = SH::read_stack(ri->sp + 2) / 10000;
37748 int32_t _b = SH::read_stack(ri->sp + 1) / 10000;
37749 bool m = (SH::read_stack(ri->sp + 0) / 10000);
37750 doGFXMonohue(_r,_g,_b,m);
37751 }
37752
37753 void FFScript::clearTint()
37754 {
37755 doClearTint();
37756 }
37757
37758 void FFScript::Tint()
37759 {
37760 int32_t _r = SH::read_stack(ri->sp + 2) / 10000;
37761 int32_t _g = SH::read_stack(ri->sp + 1) / 10000;
37762 int32_t _b = SH::read_stack(ri->sp + 0) / 10000;
37763 doTint(_r,_g,_b);
37764 }
37765
37766 void FFScript::do_fx_zap(const bool v)
37767 {
37768 int32_t out = SH::get_arg(sarg1, v);
37769
37770 if ( out ) { FFScript::do_zapout(); }
37771 else FFScript::do_zapin();
37772 }
37773
37774 void FFScript::do_fx_wavy(const bool v)
37775 {
37776 int32_t out = SH::get_arg(sarg1, v);
37777
37778 if ( out ) { FFScript::do_wavyout(); }
37779 else FFScript::do_wavyin();
37780 }
37781
37782 140824373 int32_t FFScript::getQuestHeaderInfo(int32_t type)
37783 {
37784 140824373 return quest_format[type];
37785 }
37786
37787 string get_filestr(const bool relative) //Used for 'FileSystem' functions.
37788 {
37789 int32_t strptr = get_register(sarg1)/10000;
37790 string the_string;
37791 ArrayH::getString(strptr, the_string, 512);
37792 the_string = the_string.substr(the_string.find_first_not_of('/'),string::npos); //Kill leading '/'
37793 size_t last = the_string.find_last_not_of('/');
37794 if(last!=string::npos)++last;
37795 the_string = the_string.substr(0,last); //Kill trailing '/'
37796 if(relative)
37797 {
37798 char buf[2048+1] = {0};
37799 if(FFCore.get_scriptfile_path(buf, the_string.c_str()))
37800 the_string = buf;
37801 }
37802 return the_string;
37803 }
37804
37805 void FFScript::do_checkdir(const bool is_dir)
37806 {
37807 string the_string = get_filestr(get_qr(qr_BITMAP_AND_FILESYSTEM_PATHS_ALWAYS_RELATIVE));
37808 set_register(sarg1, checkPath(the_string.c_str(), is_dir) ? 10000 : 0);
37809 }
37810
37811 void FFScript::do_fs_remove()
37812 {
37813 string the_string = get_filestr(true);
37814 set_register(sarg1, remove(the_string.c_str()) ? 0 : 10000);
37815 }
37816
37817 16 void FFScript::Play_Level_Music()
37818 {
37819 16 int32_t m=tmpscr->screen_midi;
37820
37821
1/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 switch(m)
37822 {
37823 case -2:
37824 music_stop();
37825 break;
37826
37827 case -1:
37828 16 play_DmapMusic();
37829 16 break;
37830
37831 case 1:
37832 jukebox(ZC_MIDI_OVERWORLD);
37833 break;
37834
37835 case 2:
37836 jukebox(ZC_MIDI_DUNGEON);
37837 break;
37838
37839 case 3:
37840 jukebox(ZC_MIDI_LEVEL9);
37841 break;
37842
37843 default:
37844 if(m>=4 && m<4+MAXCUSTOMMIDIS)
37845 jukebox(m+MIDIOFFSET_MAPSCR);
37846 else
37847 music_stop();
37848 }
37849 16 }
37850
37851 16 void FFScript::do_warp_ex(bool v)
37852 {
37853 16 int32_t zscript_array_ptr = SH::get_arg(sarg1, v) / 10000;
37854 16 ArrayManager am(zscript_array_ptr);
37855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(am.invalid()) return;
37856 16 int32_t zscript_array_size = am.size();
37857
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
16 switch(zscript_array_size)
37858 {
37859 case 8:
37860 // {int32_t type, int32_t dmap, int32_t screen, int32_t x, int32_t y, int32_t effect, int32_t sound, int32_t flags}
37861 {
37862 if(DEVLOGGING) zprint("FFscript.cpp running do_warp_ex with %d args\n", 8);
37863 16 int32_t tmpwarp[8]={0};
37864
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 16 times.
144 for ( int32_t q = 0; q < wexDir; q++ )
37865 {
37866 128 tmpwarp[q] = (am.get(q)/10000);
37867 128 }
37868
37869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( ((unsigned)tmpwarp[1]) >= MAXDMAPS )
37870 {
37871 Z_scripterrlog("Invalid DMap ID (%d) passed to WarpEx(). Aborting.\n", tmpwarp[1]);
37872 return;
37873 }
37874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( ((unsigned)tmpwarp[2]) >= MAPSCRS )
37875 {
37876 Z_scripterrlog("Invalid Screen ID (%d) passed to WarpEx(). Aborting.\n", tmpwarp[2]);
37877 return;
37878 }
37879 //Extra sanity guard.
37880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( DMaps[tmpwarp[1]].map*MAPSCRS+DMaps[tmpwarp[1]].xoff+tmpwarp[2] >= (int32_t)TheMaps.size() )
37881 {
37882 Z_scripterrlog("Invalid destination passed to WarpEx(). Aborting.\n");
37883 return;
37884 }
37885 //If we passed the sanity checks, populate the FFCore array and begin the action!
37886
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 16 times.
144 for ( int32_t q = 0; q < wexDir; q++ )
37887 {
37888 128 FFCore.warpex[q] = tmpwarp[q];
37889 128 }
37890 16 FFCore.warpex[wexActive] = 1;
37891 16 FFCore.warpex[wexDir] = -1;
37892
37893 16 break;
37894 }
37895 case 9:
37896 // {int32_t type, int32_t dmap, int32_t screen, int32_t x, int32_t y, int32_t effect, int32_t sound, int32_t flags, int32_t dir}
37897 {
37898 if(DEVLOGGING) zprint("FFscript.cpp running do_warp_ex with %d args\n", 9);
37899 int32_t tmpwarp[9]={0};
37900
37901 for ( int32_t q = 0; q < wexActive; q++ )
37902 {
37903 tmpwarp[q] = (am.get(q)/10000);
37904 }
37905
37906 if ( ((unsigned)tmpwarp[1]) >= MAXDMAPS )
37907 {
37908 Z_scripterrlog("Invalid DMap ID (%d) passed to WarpEx(). Aborting.\n", tmpwarp[1]);
37909 return;
37910 }
37911 if ( ((unsigned)tmpwarp[2]) >= MAPSCRS )
37912 {
37913 Z_scripterrlog("Invalid Screen ID (%d) passed to WarpEx(). Aborting.\n", tmpwarp[2]);
37914 return;
37915 }
37916 //Extra sanity guard.
37917 if ( DMaps[tmpwarp[1]].map*MAPSCRS+DMaps[tmpwarp[1]].xoff+tmpwarp[2] >= (int32_t)TheMaps.size() )
37918 {
37919 Z_scripterrlog("Invalid destination passed to WarpEx(). Aborting.\n");
37920 return;
37921 }
37922 //If we passed the sanity checks, populate the FFCore array and begin the action!
37923 for ( int32_t q = 0; q < wexActive; q++ )
37924 {
37925 FFCore.warpex[q] = tmpwarp[q];
37926 }
37927 FFCore.warpex[wexActive] = 1;
37928
37929 for ( int32_t q = 0; q < wexActive; q++ )
37930 {
37931 FFCore.warpex[q] = tmpwarp[q];
37932 }
37933
37934 //for ( int32_t q = 0; q < wexLast; q++ )
37935 //{
37936 // zprint("FFCore.warpex[%d] is: %d\n", q, FFCore.warpex[q]);
37937 //}
37938
37939 break;
37940
37941 }
37942
37943 default:
37944 {
37945 Z_scripterrlog("Array supplied to Player->WarpEx() is the wrong size!\n The array size was: &d, and valid sizes are [8] and [9].\n",zscript_array_size);
37946 break;
37947 }
37948
37949
37950
37951 }
37952 16 }
37953
37954 ///////////////////////////////
37955 //* SCRIPT ENGINE FUNCTIONS *//
37956 ////////////////////////////////////////////////////////////////////////////
37957
37958 void FFScript::clearRunningItemScripts()
37959 {
37960 //for ( byte q = 0; q < 256; q++ ) runningItemScripts[q] = 0;
37961 }
37962
37963
37964 4996 void FFScript::warpScriptCheck()
37965 {
37966
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4995 times.
4996 if(get_qr(qr_SCRIPTDRAWSINWARPS))
37967 {
37968 1 FFCore.runWarpScripts(false);
37969 1 FFCore.runWarpScripts(true); //Waitdraw
37970 1 }
37971
3/4
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 4908 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 87 times.
4995 else if(get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN) && doscript(ScriptType::PassiveSubscreen))
37972 {
37973
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 if(DMaps[currdmap].passive_sub_script != 0)
37974 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
37975
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
87 if (waitdraw(ScriptType::PassiveSubscreen) && DMaps[currdmap].passive_sub_script != 0 && doscript(ScriptType::PassiveSubscreen))
37976 {
37977 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
37978 waitdraw(ScriptType::PassiveSubscreen) = false;
37979 }
37980 87 }
37981 4996 }
37982
37983 2 void FFScript::runWarpScripts(bool waitdraw)
37984 {
37985
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 if(waitdraw)
37986 {
37987
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if ((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME))
37988 {
37989 1 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
37990 1 FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME) = false;
37991 1 }
37992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !FFCore.system_suspend[susptITEMSCRIPTENGINE] )
37993 {
37994 1 FFCore.itemScriptEngineOnWaitdraw();
37995 1 }
37996
2/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && FFCore.waitdraw(ScriptType::Player) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
37997 {
37998 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
37999 FFCore.waitdraw(ScriptType::Player) = false;
38000 }
38001
2/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
38002 {
38003 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[currdmap].script,currdmap);
38004 FFCore.waitdraw(ScriptType::DMap) = false;
38005 }
38006
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::PassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
38007 {
38008 1 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, DMaps[currdmap].passive_sub_script,currdmap);
38009 1 FFCore.waitdraw(ScriptType::PassiveSubscreen) = false;
38010 1 }
38011 //if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && active_subscreen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
38012 //{
38013 // ZScriptVersion::RunScript(ScriptType::Subscreen, DMaps[currdmap].activesubscript,currdmap);
38014 // passive_subscreen_waitdraw = false;
38015 //}
38016 //no doscript check here, becauseb of preload? Do we want to write doscript here? -Z 13th July, 2019
38017
2/10
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && FFCore.waitdraw(ScriptType::Screen) && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
38018 {
38019 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script);
38020 FFCore.waitdraw(ScriptType::Screen) = 0;
38021 }
38022 1 }
38023 else
38024 {
38025
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if ((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.doscript(ScriptType::Global, GLOBAL_SCRIPT_GAME))
38026 {
38027 1 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
38028 1 }
38029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !FFCore.system_suspend[susptITEMSCRIPTENGINE] )
38030 {
38031 1 FFCore.itemScriptEngine();
38032 1 }
38033
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 if ((!( FFCore.system_suspend[susptHEROACTIVE] )) && doscript(ScriptType::Player) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255)
38034 {
38035 1 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
38036 1 }
38037
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && doscript(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
38038 {
38039 1 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[currdmap].script,currdmap);
38040 1 }
38041
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.doscript(ScriptType::PassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
38042 {
38043 1 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, DMaps[currdmap].passive_sub_script,currdmap);
38044 1 }
38045
2/8
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
38046 {
38047 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script);
38048 }
38049 }
38050 2 }
38051
38052 17423269 void FFScript::runF6Engine()
38053 {
38054
5/6
✓ Branch 0 taken 17422581 times.
✓ Branch 1 taken 688 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 17422568 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 13 times.
17423269 if(!Quit && (GameFlags&GAMEFLAG_TRYQUIT) && !(GameFlags&GAMEFLAG_F6SCRIPT_ACTIVE))
38055 {
38056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(globalscripts[GLOBAL_SCRIPT_F6]->valid())
38057 {
38058 //Incase this was called mid-another script, store ref data
38059 push_ri();
38060 //
38061 clear_bitmap(f6_menu_buf);
38062 blit(framebuf, f6_menu_buf, 0, 0, 0, 0, 256, 224);
38063 initZScriptGlobalScript(GLOBAL_SCRIPT_F6);
38064 int32_t openingwipe = black_opening_count;
38065 int32_t openingshape = black_opening_shape;
38066 black_opening_count = 0; //No opening wipe during F6 menu
38067 if(black_opening_shape==bosFADEBLACK) black_fade(0);
38068 GameFlags |= GAMEFLAG_F6SCRIPT_ACTIVE;
38069 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
38070 pause_all_sfx();
38071
38072 auto& data = get_script_engine_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
38073 while (data.doscript)
38074 {
38075 script_drawing_commands.Clear();
38076 load_control_state();
38077 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_F6, GLOBAL_SCRIPT_F6);
38078 if (data.waitdraw)
38079 {
38080 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_F6, GLOBAL_SCRIPT_F6);
38081 data.waitdraw = false;
38082 }
38083 //Draw
38084 clear_bitmap(framebuf);
38085 if( !FFCore.system_suspend[susptCOMBOANIM] ) animate_combos();
38086 doScriptMenuDraws();
38087 //
38088 advanceframe(true,true,false);
38089 if(Quit) break; //Something quit, end script running
38090 }
38091 resume_all_sfx();
38092 script_drawing_commands.Clear();
38093 //script_drawing_commands.push_commands(tmpDrawCommands);
38094 GameFlags &= ~GAMEFLAG_F6SCRIPT_ACTIVE;
38095 //Restore opening wipe
38096 black_opening_count = openingwipe;
38097 black_opening_shape = openingshape;
38098 if(openingshape == bosFADEBLACK)
38099 {
38100 refreshTints();
38101 memcpy(tempblackpal, RAMpal, PAL_SIZE*sizeof(RGB));
38102 }
38103 //Restore script refinfo
38104 pop_ri();
38105 //
38106 if(!Quit)
38107 {
38108 if(!get_qr(qr_NOCONTINUE))
38109 f_Quit(qQUIT);
38110 }
38111 }
38112 13 else f_Quit(qQUIT);
38113 13 zc_readkey(KEY_F6);
38114 13 GameFlags &= ~GAMEFLAG_TRYQUIT;
38115 13 }
38116 17423269 }
38117 void FFScript::runOnDeathEngine()
38118 {
38119 if(!playerscripts[SCRIPT_PLAYER_DEATH]->valid()) return; //No script to run
38120 clear_bitmap(script_menu_buf);
38121 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
38122 initZScriptHeroScripts();
38123 GameFlags |= GAMEFLAG_SCRIPTMENU_ACTIVE;
38124 kill_sfx(); //No need to pause/resume; the player is dead.
38125 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
38126
38127 auto& data = get_script_engine_data(ScriptType::Player);
38128 while (data.doscript && !Quit)
38129 {
38130 script_drawing_commands.Clear();
38131 load_control_state();
38132 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_DEATH);
38133 if (data.waitdraw)
38134 {
38135 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_DEATH);
38136 data.waitdraw = false;
38137 }
38138 //Draw
38139 clear_bitmap(framebuf);
38140 if( !FFCore.system_suspend[susptCOMBOANIM] ) animate_combos();
38141 doScriptMenuDraws();
38142 //
38143 advanceframe(true);
38144 }
38145 script_drawing_commands.Clear();
38146 //script_drawing_commands.push_commands(tmpDrawCommands);
38147 GameFlags &= ~GAMEFLAG_SCRIPTMENU_ACTIVE;
38148 }
38149 121 void FFScript::runOnLaunchEngine()
38150 {
38151
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 2 times.
121 if(!globalscripts[GLOBAL_SCRIPT_ONLAUNCH]->valid()) return; //No script to run
38152 //Do NOT blit the prior screen to this bitmap; that would be the TITLE SCREEN.
38153 2 clear_to_color(script_menu_buf,BLACK);
38154 2 initZScriptGlobalScript(GLOBAL_SCRIPT_ONLAUNCH);
38155 2 GameFlags |= GAMEFLAG_SCRIPTMENU_ACTIVE;
38156 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
38157
38158 2 auto& data = get_script_engine_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
38159
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
4 while (data.doscript && !Quit)
38160 {
38161 2 script_drawing_commands.Clear();
38162 2 load_control_state();
38163 2 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH, GLOBAL_SCRIPT_ONLAUNCH);
38164
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (data.waitdraw)
38165 {
38166 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH, GLOBAL_SCRIPT_ONLAUNCH);
38167 data.waitdraw = false;
38168 }
38169 //Draw
38170 2 clear_bitmap(framebuf);
38171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if( !FFCore.system_suspend[susptCOMBOANIM] ) animate_combos();
38172
38173 2 doScriptMenuDraws();
38174 //
38175 2 advanceframe(true);
38176 }
38177 2 script_drawing_commands.Clear();
38178 //script_drawing_commands.push_commands(tmpDrawCommands);
38179 2 GameFlags &= ~GAMEFLAG_SCRIPTMENU_ACTIVE;
38180 121 }
38181 10 bool FFScript::runGenericFrozenEngine(const word script)
38182 {
38183 static int32_t local_i = 0;
38184
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if(script < 1 || script >= NUMSCRIPTSGENERIC) return false;
38185
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(!genericscripts[script]->valid()) return false; //No script to run
38186 //Store script refinfo
38187 10 push_ri();
38188 refInfo local_ri;
38189 int32_t local_stack[MAX_SCRIPT_REGISTERS];
38190 10 local_ri.Clear();
38191 10 memset(local_stack, 0, sizeof(local_stack));
38192 10 genericActiveData.push_back(&local_ri);
38193 10 generic_active_stack.push_back(&local_stack);
38194 10 bool tmp_init = gen_active_initialized;
38195 10 bool tmp_doscript = gen_active_doscript;
38196 10 gen_active_doscript = true;
38197 10 gen_active_initialized = false;
38198 //run script
38199 10 uint32_t fl = GameFlags & GAMEFLAG_SCRIPTMENU_ACTIVE;
38200 10 BITMAP* tmpbuf = script_menu_buf;
38201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(fl)
38202 {
38203 script_menu_buf = create_bitmap_ex(8,256,224);
38204 }
38205 10 clear_bitmap(script_menu_buf);
38206 10 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
38207 10 GameFlags |= GAMEFLAG_SCRIPTMENU_ACTIVE;
38208 10 ++local_i;
38209 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
38210
4/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1542 times.
✓ Branch 2 taken 1542 times.
✓ Branch 3 taken 10 times.
1552 while(gen_active_doscript && !Quit)
38211 {
38212 1542 script_drawing_commands.Clear();
38213 1542 load_control_state();
38214 1542 ZScriptVersion::RunScript(ScriptType::GenericFrozen, script, local_i);
38215 //Draw
38216 1542 clear_bitmap(framebuf);
38217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1542 times.
1542 if( !FFCore.system_suspend[susptCOMBOANIM] ) animate_combos();
38218 1542 doScriptMenuDraws();
38219 //
38220 1542 advanceframe(true);
38221 }
38222 10 script_drawing_commands.Clear();
38223 //script_drawing_commands.push_commands(tmpDrawCommands);
38224 10 --local_i;
38225 10 gen_active_doscript = tmp_doscript;
38226 10 gen_active_initialized = tmp_init;
38227 //clear
38228 10 GameFlags &= ~GAMEFLAG_SCRIPTMENU_ACTIVE;
38229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(fl)
38230 {
38231 GameFlags |= fl;
38232 destroy_bitmap(script_menu_buf);
38233 script_menu_buf = tmpbuf;
38234 }
38235 10 genericActiveData.pop_back();
38236 10 generic_active_stack.pop_back();
38237 //Restore script refinfo
38238 10 pop_ri();
38239 10 return true;
38240 10 }
38241
38242 795 bool FFScript::runActiveSubscreenScriptEngine()
38243 {
38244 795 word activesubscript = DMaps[currdmap].active_sub_script;
38245
3/4
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 754 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
795 if(!activesubscript || !dmapscripts[activesubscript]->valid()) return false; //No script to run
38246 41 word passivesubscript = DMaps[currdmap].passive_sub_script;
38247 41 word dmapactivescript = DMaps[currdmap].script;
38248 41 clear_bitmap(script_menu_buf);
38249 41 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
38250 41 initZScriptActiveSubscreenScript();
38251 41 GameFlags |= GAMEFLAG_SCRIPTMENU_ACTIVE;
38252 41 word script_dmap = currdmap;
38253 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
38254 41 pause_all_sfx();
38255 41 auto& data = get_script_engine_data(ScriptType::ActiveSubscreen);
38256
4/4
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 6772 times.
✓ Branch 2 taken 6772 times.
✓ Branch 3 taken 41 times.
6813 while (data.doscript && !Quit)
38257 {
38258 6772 script_drawing_commands.Clear();
38259 6772 load_control_state();
38260
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6772 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6772 if(get_qr(qr_DMAP_ACTIVE_RUNS_DURING_ACTIVE_SUBSCRIPT) && DMaps[script_dmap].script != 0 && doscript(ScriptType::DMap))
38261 {
38262 ZScriptVersion::RunScript(ScriptType::DMap, dmapactivescript, script_dmap);
38263 }
38264
4/6
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 6632 times.
✓ Branch 2 taken 140 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 140 times.
6772 if(get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_DURING_ACTIVE_SUBSCRIPT)!=0 && DMaps[script_dmap].passive_sub_script != 0 && FFCore.doscript(ScriptType::PassiveSubscreen))
38265 {
38266 140 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, passivesubscript, script_dmap);
38267 140 }
38268 6772 ZScriptVersion::RunScript(ScriptType::ActiveSubscreen, activesubscript, script_dmap);
38269
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6772 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6772 if(waitdraw(ScriptType::DMap) && (get_qr(qr_DMAP_ACTIVE_RUNS_DURING_ACTIVE_SUBSCRIPT) && DMaps[script_dmap].script != 0 && doscript(ScriptType::DMap)))
38270 {
38271 ZScriptVersion::RunScript(ScriptType::DMap, dmapactivescript, script_dmap);
38272 waitdraw(ScriptType::DMap) = false;
38273 }
38274
5/8
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 6633 times.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 139 times.
6772 if(waitdraw(ScriptType::PassiveSubscreen) && (get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_DURING_ACTIVE_SUBSCRIPT)!=0 && DMaps[script_dmap].passive_sub_script != 0 && FFCore.doscript(ScriptType::PassiveSubscreen)))
38275 {
38276 139 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, passivesubscript, script_dmap);
38277 139 waitdraw(ScriptType::PassiveSubscreen) = false;
38278 139 }
38279
3/4
✓ Branch 0 taken 5472 times.
✓ Branch 1 taken 1300 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5472 times.
6772 if (data.waitdraw && data.doscript)
38280 {
38281 5472 ZScriptVersion::RunScript(ScriptType::ActiveSubscreen, activesubscript, script_dmap);
38282 5472 data.waitdraw = false;
38283 5472 }
38284 //Draw
38285 6772 clear_bitmap(framebuf);
38286
2/4
✓ Branch 0 taken 6772 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6772 times.
6772 if(currdmap == script_dmap && ( !FFCore.system_suspend[susptCOMBOANIM] ) ) animate_combos();
38287 6772 doScriptMenuDraws();
38288 //
38289 6772 advanceframe(true);
38290 //Handle warps; run game_loop once!
38291
1/2
✓ Branch 0 taken 6772 times.
✗ Branch 1 not taken.
6772 if(currdmap != script_dmap)
38292 {
38293 activesubscript = DMaps[currdmap].active_sub_script;
38294 if(!activesubscript || !dmapscripts[activesubscript]->valid()) return true; //No script to run
38295 passivesubscript = DMaps[currdmap].passive_sub_script;
38296 dmapactivescript = DMaps[currdmap].script;
38297 script_dmap = currdmap;
38298 //Reset the background image
38299 game_loop();
38300 clear_bitmap(script_menu_buf);
38301 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
38302 //Now loop without advancing frame, so that the subscreen script can draw immediately.
38303 }
38304 }
38305 41 resume_all_sfx();
38306 41 script_drawing_commands.Clear();
38307 //script_drawing_commands.push_commands(tmpDrawCommands);
38308 41 GameFlags &= ~GAMEFLAG_SCRIPTMENU_ACTIVE;
38309 41 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
38310 41 return true;
38311 795 }
38312 420 bool FFScript::runOnMapScriptEngine()
38313 {
38314 420 word onmap_script = DMaps[currdmap].onmap_script;
38315
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 417 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
420 if(!onmap_script || !dmapscripts[onmap_script]->valid()) return false; //No script to run
38316 3 clear_bitmap(script_menu_buf);
38317 3 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
38318 3 initZScriptOnMapScript();
38319 3 GameFlags |= GAMEFLAG_SCRIPTMENU_ACTIVE;
38320 3 word script_dmap = currdmap;
38321 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
38322 3 pause_all_sfx();
38323
38324 3 auto& data = get_script_engine_data(ScriptType::OnMap);
38325
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 114 times.
✓ Branch 3 taken 3 times.
117 while (data.doscript && !Quit)
38326 {
38327 114 script_drawing_commands.Clear();
38328 114 load_control_state();
38329 114 ZScriptVersion::RunScript(ScriptType::OnMap, onmap_script, script_dmap);
38330
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114 if (data.waitdraw && data.doscript)
38331 {
38332 ZScriptVersion::RunScript(ScriptType::OnMap, onmap_script, script_dmap);
38333 data.waitdraw = false;
38334 }
38335 //Draw
38336 114 clear_bitmap(framebuf);
38337
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if(currdmap == script_dmap && ( !FFCore.system_suspend[susptCOMBOANIM] ) ) animate_combos();
38338 114 doScriptMenuDraws();
38339 //
38340 114 advanceframe(true);
38341 //Handle warps; run game_loop once!
38342
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(currdmap != script_dmap)
38343 {
38344 onmap_script = DMaps[currdmap].onmap_script;
38345 if(!onmap_script || !dmapscripts[onmap_script]->valid()) return true; //No script to run
38346 script_dmap = currdmap;
38347 //Reset the background image
38348 game_loop();
38349 clear_bitmap(script_menu_buf);
38350 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
38351 //Now loop without advancing frame, so that the subscreen script can draw immediately.
38352 }
38353 }
38354 3 resume_all_sfx();
38355 3 script_drawing_commands.Clear();
38356 //script_drawing_commands.push_commands(tmpDrawCommands);
38357 3 GameFlags &= ~GAMEFLAG_SCRIPTMENU_ACTIVE;
38358 3 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
38359 3 return true;
38360 420 }
38361
38362 8430 void FFScript::doScriptMenuDraws()
38363 {
38364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8430 times.
8430 BITMAP* menu_buf = ((GameFlags & GAMEFLAG_F6SCRIPT_ACTIVE) != 0) ? f6_menu_buf : script_menu_buf;
38365 8430 blit(menu_buf, framebuf, 0, 0, 0, 0, 256, 224);
38366 //Script draws
38367 8430 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
38368 8430 }
38369
38370 102 void FFScript::runOnSaveEngine()
38371 {
38372
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(globalscripts[GLOBAL_SCRIPT_ONSAVE]->valid())
38373 {
38374 push_ri();
38375 //Prevent getting here via Quit from causing a forced-script-quit after 1000 commands!
38376 int32_t tQuit = Quit;
38377 Quit = 0;
38378 //
38379 initZScriptGlobalScript(GLOBAL_SCRIPT_ONSAVE);
38380 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE, GLOBAL_SCRIPT_ONSAVE);
38381 //
38382 pop_ri();
38383 Quit = tQuit;
38384 }
38385 102 }
38386
38387 8066928 bool FFScript::itemScriptEngine()
38388 {
38389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8066928 times.
8066928 if ( FFCore.system_suspend[susptITEMSCRIPTENGINE] ) return false;
38390 //zprint("Trying to check if an %s is running.\n","item script");
38391
2/2
✓ Branch 0 taken 2065133568 times.
✓ Branch 1 taken 8066928 times.
2073200496 for ( int32_t q = 0; q < MAXITEMS; q++ )
38392 {
38393
38394 //zprint("Checking item ID: %d\n",q);
38395
3/4
✓ Branch 0 taken 18895887 times.
✓ Branch 1 taken 2046237681 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18895887 times.
2065133568 if ( itemsbuf[q].script <= 0 || itemsbuf[q].script > NUMSCRIPTITEM ) continue; // > NUMSCRIPTITEM as someone could force an invaid script slot!
38396
38397 18895887 auto& data = get_script_engine_data(ScriptType::Item, q);
38398
2/2
✓ Branch 0 taken 3306 times.
✓ Branch 1 taken 18892581 times.
18895887 if ( data.doscript < 1 ) continue;
38399
38400 //Passive items
38401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3306 times.
3306 if (((itemsbuf[q].flags&ITEM_PASSIVESCRIPT)))
38402 {
38403 if(game->item[q] && (get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
38404 {
38405 if(get_qr(qr_PASSIVE_ITEM_SCRIPT_ONLY_HIGHEST)
38406 && current_item(itemsbuf[q].family) > itemsbuf[q].fam_type)
38407 data.doscript = 0;
38408 else ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q&0xFFF);
38409 if(!data.doscript) //Item script ended. Clear the data, if any remains.
38410 {
38411 data.ref.Clear();
38412 data.initialized = false;
38413 data.waitdraw = false;
38414 FFScript::deallocateAllArrays(ScriptType::Item, q);
38415 }
38416 }
38417 }
38418 else
38419 {
38420
38421 //Normal Items
38422 //zprint("Running ItemScriptEngine() for item ID: %dn", q);
38423 /*! What happens here: When an item script is first run by the user using that utem, the script runs for one frame.
38424 After executing RunScript(), item_doscript is set to '1' in hero.cpp.
38425 If the quest allows the item to continue running, the itemScriptEngine() function ignores running the
38426 same item script (again) that frame, and insteads increments item_doscript to '2'.
38427 If item_doscript == 2, then we know we are on the second frame, and we run it perpetually.
38428 If the QR to enable item scripts to run for more than one frame is not enabled, then item_doscript is set to '0'.
38429 If the item flag 'PERPETUAL SCRIPT' is enabled, then we ignore the lack of item_doscript==2.
38430 This allows passive item scripts to function.
38431 */
38432
38433 3306 auto& data = get_script_engine_data(ScriptType::Item, q);
38434
38435
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3293 times.
3306 if ( data.doscript == 1 ) // FIrst frame, normally set in hero.cpp
38436 {
38437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if ( get_qr(qr_ITEMSCRIPTSKEEPRUNNING) )
38438 {
38439 13 data.doscript = 2;
38440 13 }
38441 13 }
38442
1/2
✓ Branch 0 taken 3293 times.
✗ Branch 1 not taken.
3293 else if (data.doscript == 2) //Second frame and later, if scripts continue to run.
38443 {
38444 3293 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q&0xFFF);
38445 3293 }
38446 else if (data.doscript == 3) //Run via itemdata->RunScript
38447 {
38448 if ( (get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
38449 {
38450 data.doscript = 2; //Reduce to normal run status
38451 }
38452 else
38453 {
38454 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q & 0xFFF);
38455 data.doscript = 0;
38456 }
38457 }
38458 else if(data.doscript==4) //Item set itself false, kill script and clear data here
38459 {
38460 data.doscript = 0;
38461 }
38462
2/2
✓ Branch 0 taken 3278 times.
✓ Branch 1 taken 28 times.
3306 if(data.doscript==0) //Item script ended. Clear the data, if any remains.
38463 {
38464 28 data.ref.Clear();
38465 28 data.initialized = false;
38466 28 data.waitdraw = false;
38467 28 FFScript::deallocateAllArrays(ScriptType::Item, q);
38468 28 }
38469 }
38470 3306 }
38471 8066928 return false;
38472 8066928 }
38473
38474 8154053 bool FFScript::itemScriptEngineOnWaitdraw()
38475 {
38476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8154053 times.
8154053 if ( FFCore.system_suspend[susptITEMSCRIPTENGINE] ) return false;
38477 //zprint("Trying to check if an %s is running.\n","item script");
38478
2/2
✓ Branch 0 taken 2087437568 times.
✓ Branch 1 taken 8154053 times.
2095591621 for ( int32_t q = 0; q < MAXITEMS; q++ )
38479 {
38480 //zprint("Checking item ID: %d\n",q);
38481
3/4
✓ Branch 0 taken 19399133 times.
✓ Branch 1 taken 2068038435 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19399133 times.
2087437568 if ( itemsbuf[q].script <= 0 || itemsbuf[q].script > NUMSCRIPTITEM ) continue; // > NUMSCRIPTITEM as someone could force an invaid script slot!
38482
38483 19399133 auto& data = get_script_engine_data(ScriptType::Item, q);
38484
38485
2/2
✓ Branch 0 taken 3278 times.
✓ Branch 1 taken 19395855 times.
19399133 if ( data.doscript < 1 ) continue;
38486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3278 times.
3278 if (!data.waitdraw) continue;
38487 else data.waitdraw = false;
38488
38489 //zprint("Running ItemScriptEngine() for item ID: %dn", q);
38490 /*! What happens here: When an item script is first run by the user using that utem, the script runs for one frame.
38491 After executing RunScript(), item_doscript is set to '1' in hero.cpp.
38492 If the quest allows the item to continue running, the itemScriptEngine() function ignores running the
38493 same item script (again) that frame, and insteads increments item_doscript to '2'.
38494 If item_doscript == 2, then we know we are on the second frame, and we run it perpetually.
38495 If the QR to enable item scripts to run for more than one frame is not enabled, then item_doscript is set to '0'.
38496 If the item flag 'PERPETUAL SCRIPT' is enabled, then we ignore the lack of item_doscript==2.
38497 This allows passive item scripts to function.
38498 */
38499 //Passive items
38500 if ((itemsbuf[q].flags&ITEM_PASSIVESCRIPT))
38501 {
38502 if(game->item[q] && (get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
38503 {
38504 if(get_qr(qr_PASSIVE_ITEM_SCRIPT_ONLY_HIGHEST)
38505 && current_item(itemsbuf[q].family) > itemsbuf[q].fam_type)
38506 data.doscript = 0;
38507 else ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q&0xFFF);
38508 if(!data.doscript) //Item script ended. Clear the data, if any remains.
38509 {
38510 data.ref.Clear();
38511 data.initialized = false;
38512 data.waitdraw = false;
38513 FFScript::deallocateAllArrays(ScriptType::Item, q);
38514 }
38515 }
38516 }
38517 else
38518 {
38519 //Normal items
38520 if ( data.doscript == 1 ) // FIrst frame, normally set in hero.cpp
38521 {
38522 if ( get_qr(qr_ITEMSCRIPTSKEEPRUNNING) )
38523 {
38524 data.doscript = 2;
38525 }
38526 else data.doscript = 0;
38527 }
38528 else if (data.doscript == 2) //Second frame and later, if scripts continue to run.
38529 {
38530 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q&0xFFF);
38531 }
38532 else if (data.doscript == 3) //Run via itemdata->RunScript
38533 {
38534 if ( (get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
38535 {
38536 data.doscript = 2; //Reduce to normal run status
38537 }
38538 else
38539 {
38540 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q & 0xFFF);
38541 data.doscript = 0;
38542 }
38543 }
38544 else if(data.doscript==4) //Item set itself false, kill script and clear data here.
38545 {
38546 data.doscript = 0;
38547 }
38548 if(!data.doscript) //Item script ended. Clear the data, if any remains.
38549 {
38550 data.ref.Clear();
38551 data.initialized = false;
38552 data.waitdraw = false;
38553 FFScript::deallocateAllArrays(ScriptType::Item, q);
38554 }
38555 }
38556 }
38557 8154053 return false;
38558 8154053 }
38559 7335781 void FFScript::npcScriptEngineOnWaitdraw()
38560 {
38561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7335781 times.
7335781 if ( FFCore.system_suspend[susptNPCSCRIPTS] ) return;
38562 7335781 guys.run_script(MODE_WAITDRAW);
38563 7335781 }
38564
38565 7261355 void FFScript::eweaponScriptEngine()
38566 {
38567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7261355 times.
7261355 if ( FFCore.system_suspend[susptEWEAPONSCRIPTS] ) return;
38568 7261355 Ewpns.run_script(MODE_NORMAL);
38569 7261355 }
38570
38571 7335781 void FFScript::lweaponScriptEngineOnWaitdraw()
38572 {
38573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7335781 times.
7335781 if ( FFCore.system_suspend[susptLWEAPONSCRIPTS] ) return;
38574 7335781 Lwpns.run_script(MODE_WAITDRAW);
38575 7335781 }
38576
38577 7348666 void FFScript::eweaponScriptEngineOnWaitdraw()
38578 {
38579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7348666 times.
7348666 if ( FFCore.system_suspend[susptEWEAPONSCRIPTS] ) return;
38580 7348666 Ewpns.run_script(MODE_WAITDRAW);
38581 7348666 }
38582
38583 7261355 void FFScript::itemSpriteScriptEngine()
38584 {
38585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7261355 times.
7261355 if ( FFCore.system_suspend[susptITEMSPRITESCRIPTS] ) return;
38586 7261355 items.run_script(MODE_NORMAL);
38587 7261355 }
38588
38589 7348666 void FFScript::itemSpriteScriptEngineOnWaitdraw()
38590 {
38591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7348666 times.
7348666 if ( FFCore.system_suspend[susptITEMSPRITESCRIPTS] ) return;
38592 7348666 items.run_script(MODE_WAITDRAW);
38593 7348666 }
38594
38595
38596 int32_t FFScript::getTime(int32_t type)
38597 {
38598 //struct tm *tm_struct = localtime(time(NULL));
38599 struct tm * tm_struct;
38600 time_t sysRTC;
38601 time (&sysRTC);
38602 tm_struct = localtime (&sysRTC);
38603 int32_t rval = -1;
38604
38605 switch(type)
38606 {
38607 case curyear:
38608 {
38609 //Year format starts at 1900, yeat
38610 //A raw read of '2018' would be '118', so we add 1900 to it to derive the actual year.
38611 rval = tm_struct->tm_year + 1900; break;
38612
38613 }
38614 case curmonth:
38615 {
38616 //Months start at 0, but we want 1->12
38617 //al_trace("The current month is: %d\n",month);
38618 rval = tm_struct->tm_mon +1; break;
38619 }
38620 case curday_month:
38621 {
38622 rval = tm_struct->tm_mday; break;
38623 }
38624 case curday_week:
38625 {
38626 //It seems that weekdays are a value range of 1 to 7.
38627 rval = tm_struct->tm_wday; break;
38628 }
38629 case curhour:
38630 {
38631 rval = tm_struct->tm_hour; break;
38632 }
38633 case curminute:
38634 {
38635 rval = tm_struct->tm_min; break;
38636 }
38637 case cursecond:
38638 {
38639 rval = tm_struct->tm_sec; break;
38640 }
38641 case curdayyear:
38642 {
38643 //The day (n/365) out of the entire year.
38644 rval = tm_struct->tm_yday; break;
38645 }
38646 case curDST:
38647 {
38648 //Returns if the user is in a Time Zone with Daylight TIme of some sort.
38649 //View the time.h docs for the actual values of this struct element.
38650 rval = tm_struct->tm_isdst;; break;
38651 }
38652 default:
38653 {
38654 al_trace("Invalid category passed to GetSystemTime(%d)\n",type);
38655 rval = -1; break;
38656 }
38657
38658 }
38659 return rval;
38660 }
38661
38662 void FFScript::do_isdeadnpc()
38663 {
38664 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38665 if(GuyH::loadNPC(ri->guyref, "npc->isDead") == SH::_NoError)
38666 {
38667 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38668 //int32_t dead = (int32_t)e->Dead(GuyH::getNPCIndex(ri->guyref));
38669 //GuyH::getNPC()->Dead(GuyH::getNPCIndex(ri->guyref));
38670 set_register(sarg1,
38671 ((GuyH::getNPC()->dying && !GuyH::getNPC()->immortal)
38672 ? 10000 : 0));
38673 }
38674 else set_register(sarg1, 0);
38675 }
38676
38677
38678 void FFScript::do_canslidenpc()
38679 {
38680
38681 if(GuyH::loadNPC(ri->guyref, "npc->CanSlide") == SH::_NoError)
38682 {
38683 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38684 //bool candoit = e->can_slide();
38685 set_register(sarg1, ((GuyH::getNPC()->can_slide()) ? 10000 : 0));
38686 }
38687 else set_register(sarg1, -10000);
38688 }
38689
38690 void FFScript::do_slidenpc()
38691 {
38692
38693 if(GuyH::loadNPC(ri->guyref, "npc->Slide()") == SH::_NoError)
38694 {
38695 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38696 //bool candoit = e->slide();
38697 set_register(sarg1, ((GuyH::getNPC()->slide())*10000));
38698 }
38699 else set_register(sarg1, -10000);
38700 }
38701
38702 void FFScript::do_npc_stopbgsfx()
38703 {
38704 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38705 if(GuyH::loadNPC(ri->guyref, "npc->StopBGSFX()") == SH::_NoError)
38706 {
38707 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38708 //e->stop_bgsfx(GuyH::getNPCIndex(ri->guyref));
38709 GuyH::getNPC()->stop_bgsfx(GuyH::getNPCIndex(ri->guyref));
38710 }
38711 }
38712
38713 void FFScript::do_npc_delete()
38714 {
38715 if(GuyH::loadNPC(ri->guyref, "npc->Remove()") == SH::_NoError)
38716 {
38717 auto ind = GuyH::getNPCIndex(ri->guyref);
38718 GuyH::getNPC()->stop_bgsfx(ind);
38719 guys.del(ind);
38720 }
38721 }
38722
38723 2 void FFScript::do_lweapon_delete()
38724 {
38725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(0!=(s=checkLWpn(ri->lwpn,"Remove()")))
38726 {
38727
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(s==Hero.lift_wpn)
38728 {
38729 delete s;
38730 Hero.lift_wpn = nullptr;
38731 }
38732 2 else Lwpns.del(LwpnH::getLWeaponIndex(ri->lwpn));
38733 2 }
38734 2 }
38735
38736 void FFScript::do_eweapon_delete()
38737 {
38738 if(0!=(s=checkEWpn(ri->ewpn,"Remove()")))
38739 {
38740 Ewpns.del(EwpnH::getEWeaponIndex(ri->ewpn));
38741 }
38742 }
38743
38744 8 bool FFScript::do_itemsprite_delete()
38745 {
38746
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(0!=(s=checkItem(ri->itemref)))
38747 {
38748 8 auto ind = ItemH::getItemIndex(ri->itemref);
38749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!items.del(ind)) return false;
38750
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 8 times.
55 for(int32_t i=0; i<Lwpns.Count(); i++)
38751 {
38752 47 weapon *w = (weapon*)Lwpns.spr(i);
38753
38754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(w->dragging==ind)
38755 {
38756 w->dragging=-1;
38757 }
38758
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 else if(w->dragging>ind)
38759 {
38760 w->dragging-=1;
38761 }
38762 47 }
38763 8 return true;
38764 }
38765 return false;
38766 8 }
38767
38768 408 void FFScript::updateIncludePaths()
38769 {
38770 408 includePaths.clear();
38771 408 int32_t pos = 0;
38772
2/2
✓ Branch 0 taken 1224 times.
✓ Branch 1 taken 408 times.
1632 for ( int32_t q = 0; includePathString[pos]; ++q )
38773 {
38774 1224 int32_t dest = 0;
38775 1224 char buf[2048] = {0};
38776
4/4
✓ Branch 0 taken 1224 times.
✓ Branch 1 taken 9792 times.
✓ Branch 2 taken 9792 times.
✓ Branch 3 taken 1224 times.
11016 while(includePathString[pos] != ';' && includePathString[pos])
38777 {
38778 9792 buf[dest] = includePathString[pos];
38779 9792 ++pos;
38780 9792 ++dest;
38781 }
38782 1224 ++pos;
38783
1/2
✓ Branch 0 taken 1224 times.
✗ Branch 1 not taken.
1224 std::string str(buf);
38784
1/2
✓ Branch 0 taken 1224 times.
✗ Branch 1 not taken.
1224 includePaths.push_back(str);
38785 1224 }
38786 408 }
38787
38788 408 void FFScript::initRunString()
38789 {
38790 408 memset(scriptRunString,0,sizeof(scriptRunString));
38791 408 strcpy(scriptRunString,zc_get_config("Compiler","run_string","run",App::zscript));
38792 408 }
38793
38794 408 void FFScript::initIncludePaths()
38795 {
38796 408 memset(includePathString,0,sizeof(includePathString));
38797 408 FILE* f = fopen("includepaths.txt", "r");
38798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(f)
38799 {
38800 int32_t pos = 0;
38801 int32_t c;
38802 do
38803 {
38804 c = fgetc(f);
38805 if(c!=EOF)
38806 includePathString[pos++] = c;
38807 }
38808 while(c!=EOF && pos<MAX_INCLUDE_PATH_CHARS);
38809 if(pos<MAX_INCLUDE_PATH_CHARS)
38810 includePathString[pos] = '\0';
38811 includePathString[MAX_INCLUDE_PATH_CHARS-1] = '\0';
38812 fclose(f);
38813 }
38814 408 else strcpy(includePathString, "include/;headers/;scripts/;");
38815 408 al_trace("Full path string is: ");
38816 408 safe_al_trace(includePathString);
38817 408 al_trace("\n");
38818 408 updateIncludePaths();
38819
38820
2/2
✓ Branch 0 taken 1224 times.
✓ Branch 1 taken 408 times.
1632 for ( size_t q = 0; q < includePaths.size(); ++q )
38821 {
38822 1224 al_trace("Include path %zu: ",q);
38823 1224 safe_al_trace(includePaths.at(q));
38824 1224 al_trace("\n");
38825 1224 }
38826 408 }
38827
38828 void FFScript::do_npcattack()
38829 {
38830
38831 if(GuyH::loadNPC(ri->guyref, "npc->Attack()") == SH::_NoError)
38832 {
38833 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38834 //e->FireWeapon();
38835 //we could just do:
38836 GuyH::getNPC()->FireWeapon();
38837 }
38838 }
38839 void FFScript::do_npc_newdir()
38840 {
38841 int32_t arrayptr = get_register(sarg1) / 10000;
38842 ArrayManager am(arrayptr);
38843 if(am.invalid()) return;
38844 int32_t sz = am.size();
38845
38846 if(GuyH::loadNPC(ri->guyref, "npc->NewDir()") == SH::_NoError)
38847 {
38848 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38849
38850 if ( sz != -1 )
38851 {
38852 if ( sz != 3 )
38853 {
38854 Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
38855 return;
38856 }
38857 GuyH::getNPC()->newdir((am.get(0)/10000), (am.get(1)/10000),
38858 (am.get(2)/10000));
38859 }
38860 //else e->newdir();
38861 else GuyH::getNPC()->newdir();
38862 }
38863 }
38864
38865 void FFScript::do_npc_constwalk()
38866 {
38867 int32_t arrayptr = get_register(sarg1) / 10000;
38868 ArrayManager am(arrayptr);
38869 if(am.invalid()) return;
38870 int32_t sz = am.size();
38871
38872 if(GuyH::loadNPC(ri->guyref, "npc->ConstantWalk()") == SH::_NoError)
38873 {
38874 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38875
38876 if ( sz != -1 )
38877 {
38878 if ( sz != 3 )
38879 {
38880 Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
38881 return;
38882 }
38883 GuyH::getNPC()->constant_walk( (am.get(0)/10000), (am.get(1)/10000),
38884 (am.get(2)/10000) );
38885 }
38886 else GuyH::getNPC()->constant_walk();//e->constant_walk();
38887 }
38888 }
38889
38890 void FFScript::do_npc_varwalk()
38891 {
38892 int32_t arrayptr = get_register(sarg2) / 10000;
38893 ArrayManager am(arrayptr);
38894 if(am.invalid()) return;
38895 int32_t sz = am.size();
38896
38897 if(GuyH::loadNPC(ri->guyref, "npc->VariableWalk()") == SH::_NoError)
38898 {
38899 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38900
38901 if ( sz == 3 )
38902 {
38903
38904 GuyH::getNPC()->variable_walk( (am.get(0)/10000), (am.get(1)/10000),
38905 (am.get(2)/10000) );
38906 }
38907 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
38908 }
38909 }
38910
38911 void FFScript::do_npc_varwalk8()
38912 {
38913 int32_t arrayptr = get_register(sarg1) / 10000;
38914 ArrayManager am(arrayptr);
38915 if(am.invalid()) return;
38916 int32_t sz = am.size();
38917
38918 if(GuyH::loadNPC(ri->guyref, "npc->VariableWalk8()") == SH::_NoError)
38919 {
38920 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38921
38922 if ( sz == 4 )
38923 {
38924 GuyH::getNPC()->variable_walk_8( (am.get(0)/10000), (am.get(1)/10000),
38925 (am.get(2)/10000), (am.get(3)/10000) );
38926 }
38927 else if ( sz == 8 )
38928 {
38929 GuyH::getNPC()->variable_walk_8( (am.get(0)/10000), (am.get(1)/10000),
38930 (am.get(2)/10000), (am.get(3)/10000),
38931 (am.get(4)/10000), (am.get(5)/10000),
38932 (am.get(6)/10000), (am.get(7)/10000)
38933 );
38934 }
38935 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
38936 }
38937 }
38938
38939 void FFScript::do_npc_constwalk8()
38940 {
38941 int32_t arrayptr = get_register(sarg1) / 10000;
38942 ArrayManager am(arrayptr);
38943 if(am.invalid()) return;
38944 int32_t sz = am.size();
38945
38946 if(GuyH::loadNPC(ri->guyref, "npc->ConstantWalk8()") == SH::_NoError)
38947 {
38948 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38949
38950 if ( sz == 3 )
38951 {
38952 GuyH::getNPC()->constant_walk_8( (am.get(0)/10000), (am.get(1)/10000),
38953 (am.get(2)/10000) );
38954 }
38955
38956 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
38957 }
38958 }
38959
38960
38961 void FFScript::do_npc_haltwalk()
38962 {
38963 int32_t arrayptr = get_register(sarg1) / 10000;
38964 ArrayManager am(arrayptr);
38965 if(am.invalid()) return;
38966 int32_t sz = am.size();
38967
38968 if(GuyH::loadNPC(ri->guyref, "npc->HaltingWalk()") == SH::_NoError)
38969 {
38970 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38971
38972 if ( sz == 5 )
38973 {
38974 GuyH::getNPC()->halting_walk( (am.get(0)/10000), (am.get(1)/10000),
38975 (am.get(2)/10000), (am.get(3)/10000),
38976 (am.get(4)/10000));
38977 }
38978 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
38979 }
38980 }
38981
38982 void FFScript::do_npc_haltwalk8()
38983 {
38984 int32_t arrayptr = get_register(sarg1) / 10000;
38985 ArrayManager am(arrayptr);
38986 if(am.invalid()) return;
38987 int32_t sz = am.size();
38988
38989 if(GuyH::loadNPC(ri->guyref, "npc->HaltingWalk8()") == SH::_NoError)
38990 {
38991 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38992
38993 if ( sz == 6 )
38994 {
38995
38996 GuyH::getNPC()->halting_walk_8( (am.get(0)/10000), (am.get(1)/10000),
38997 (am.get(2)/10000), (am.get(3)/10000),
38998 (am.get(4)/10000),(am.get(5)/10000));
38999 }
39000 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
39001 }
39002 }
39003
39004
39005 void FFScript::do_npc_floatwalk()
39006 {
39007 int32_t arrayptr = get_register(sarg1) / 10000;
39008 ArrayManager am(arrayptr);
39009 if(am.invalid()) return;
39010 int32_t sz = am.size();
39011
39012 if(GuyH::loadNPC(ri->guyref, "npc->FloatingWalk()") == SH::_NoError)
39013 {
39014 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
39015
39016 if ( sz == 3 )
39017 {
39018
39019 GuyH::getNPC()->floater_walk( (am.get(0)/10000), (am.get(1)/10000),
39020 (zfix)(am.get(2)/10000));
39021
39022 }
39023 else if ( sz == 7 )
39024 {
39025
39026 GuyH::getNPC()->floater_walk( (am.get(0)/10000), (am.get(1)/10000),
39027 (zfix)(am.get(2)/10000), (zfix)(am.get(3)/10000),
39028 (am.get(4)/10000),(am.get(5)/10000),
39029 (am.get(6)/10000));
39030 }
39031 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
39032 }
39033 }
39034
39035 void FFScript::do_npc_breathefire()
39036 {
39037 bool seek = (get_register(sarg1));
39038 if(GuyH::loadNPC(ri->guyref, "npc->BreathAttack()") == SH::_NoError)
39039 {
39040 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
39041 GuyH::getNPC()->FireBreath(seek);
39042
39043 }
39044 }
39045
39046
39047 void FFScript::do_npc_newdir8()
39048 {
39049 int32_t arrayptr = get_register(sarg1) / 10000;
39050 ArrayManager am(arrayptr);
39051 if(am.invalid()) return;
39052 int32_t sz = am.size();
39053
39054 if(GuyH::loadNPC(ri->guyref, "npc->NewDir8()") == SH::_NoError)
39055 {
39056 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
39057
39058 if ( sz == 3 )
39059 {
39060
39061 GuyH::getNPC()->newdir_8( (am.get(0)/10000), (am.get(1)/10000),
39062 (am.get(2)/10000));
39063
39064 }
39065 else if ( sz == 7 )
39066 {
39067
39068 GuyH::getNPC()->newdir_8( (am.get(0)/10000), (am.get(1)/10000),
39069 (am.get(2)/10000), (am.get(3)/10000),
39070 (am.get(4)/10000),(am.get(5)/10000),
39071 (am.get(6)/10000));
39072 }
39073 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
39074 }
39075 }
39076
39077
39078 int32_t FFScript::npc_collision()
39079 {
39080 int32_t isColl = 0;
39081 if(GuyH::loadNPC(ri->guyref, "npc->Collision()") == SH::_NoError)
39082 {
39083 int32_t _obj_type = (ri->d[rINDEX] / 10000);
39084 int32_t _obj_ptr = (ri->d[rINDEX2]);
39085
39086 switch(_obj_type)
39087 {
39088 case obj_type_lweapon:
39089 {
39090 isColl = 0;
39091 break;
39092 }
39093 case obj_type_eweapon:
39094 {
39095 isColl = 0;
39096 break;
39097 }
39098 case obj_type_npc:
39099 {
39100 isColl = 0;
39101 break;
39102 }
39103 case obj_type_player:
39104 {
39105 isColl = 0;
39106 break;
39107 }
39108 case obj_type_ffc:
39109 {
39110 _obj_ptr *= 10000; _obj_ptr -= 1;
39111 isColl = 0;
39112 break;
39113 }
39114 case obj_type_combo_pos:
39115 {
39116 _obj_ptr *= 10000;
39117 isColl = 0;
39118 break;
39119 }
39120 case obj_type_item:
39121 {
39122 isColl = 0;
39123 break;
39124 }
39125 default:
39126 {
39127 Z_scripterrlog("Invalid object type (%d) passed to npc->Collision(int32_t type, int32_t ptr)\n", _obj_type);
39128 isColl = 0;
39129 break;
39130 }
39131 }
39132 }
39133
39134 return isColl;
39135 }
39136
39137
39138 int32_t FFScript::npc_linedup()
39139 {
39140 if(GuyH::loadNPC(ri->guyref, "npc->LinedUp()") == SH::_NoError)
39141 {
39142 int32_t range = (ri->d[rINDEX] / 10000);
39143 bool dir8 = (ri->d[rINDEX2]);
39144 return (int32_t)(GuyH::getNPC()->lined_up(range,dir8)*10000);
39145 }
39146
39147 return 0;
39148 }
39149
39150
39151 void FFScript::do_npc_hero_in_range(const bool v)
39152 {
39153 int32_t dist = get_register(sarg1) / 10000;
39154 if(GuyH::loadNPC(ri->guyref, "npc->LinedUp()") == SH::_NoError)
39155 {
39156 bool in_range = GuyH::getNPC()->HeroInRange(dist);
39157 set_register(sarg1, (in_range ? 10000 : 0)); //This isn't setting the right value, it seems.
39158 }
39159 else set_register(sarg2, 0);
39160 }
39161
39162
39163
39164
39165
39166
39167 void FFScript::do_npc_simulate_hit(const bool v)
39168 {
39169 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
39170 ArrayManager am(arrayptr);
39171 if(am.invalid()) return;
39172 int32_t sz = am.size();
39173 bool ishit = false;
39174
39175 if(GuyH::loadNPC(ri->guyref, "npc->SimulateHit()") == SH::_NoError)
39176 {
39177 // zprint("Trying to simulate a hit on npc\n");
39178 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
39179 if ( sz == 2 ) //type and pointer
39180 {
39181 // int32_t type = am.get(0)/10000;
39182
39183 //switch(type)
39184 //{
39185 // case simulate_hit_type_weapon:
39186 // {
39187 // ishit = e->hit(*);
39188 // break;
39189 // }
39190 // case simulate_hit_type_sprite:
39191 // {
39192 // ishit = e->hit(*);
39193 // break;
39194 // }
39195 //}
39196 ishit = false;
39197 }
39198 if ( sz == 6 ) //hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz);
39199 {
39200 ishit = GuyH::getNPC()->hit( (am.get(0)/10000), (am.get(1)/10000),
39201 (am.get(2)/10000), (am.get(3)/10000),
39202 (am.get(4)/10000), (am.get(5)/10000) );
39203
39204 }
39205 else
39206 {
39207 Z_scripterrlog("Invalid array size (%d) passed to npc->SimulateHit(). The array size must be [1] or [3].\n", sz);
39208 ishit = false;
39209 }
39210 }
39211 set_register(sarg1, ( ishit ? 10000 : 0));
39212 }
39213
39214 void FFScript::do_npc_knockback(const bool v)
39215 {
39216 int32_t time = SH::get_arg(sarg1, v) / 10000;
39217 int32_t dir = SH::get_arg(sarg2, v) / 10000;
39218 int32_t spd = vbound(ri->d[rINDEX] / 10000, 0, 255);
39219 //zprint("Knockback: time %d,dir %d,spd %d\n",time,dir,spd);
39220 bool ret = false;
39221
39222 if(GuyH::loadNPC(ri->guyref, "npc->Knockback()") == SH::_NoError)
39223 {
39224 ret = GuyH::getNPC()->knockback(time, dir, spd);
39225 }
39226 set_register(sarg1, ( ret ? 10000 : 0));
39227 }
39228
39229 void FFScript::do_npc_add(const bool v)
39230 {
39231
39232 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
39233 ArrayManager am(arrayptr);
39234 if(am.invalid()) return;
39235 int32_t sz = am.size();
39236
39237 int32_t id = 0, nx = 0, ny = 0;
39238
39239 if ( sz < 1 )
39240 {
39241 Z_scripterrlog("Invalid array size (%d) passed to npc->Create(). The array size must be [1] or [3].\n", sz);
39242 return;
39243 }
39244 else //size is valid
39245 {
39246 id = (am.get(0)/10000);
39247
39248 if ( sz == 3 ) //x and y
39249 {
39250 nx = (am.get(1)/10000);
39251 ny = (am.get(2)/10000);
39252 }
39253 }
39254
39255
39256 if(BC::checkGuyID(id, "npc->Create()") != SH::_NoError)
39257 return;
39258
39259 //If we make a segmented enemy there'll be more than one sprite created
39260 word numcreated = addenemy(nx, ny, id, -10);
39261
39262 if(numcreated == 0)
39263 {
39264 ri->guyref = MAX_DWORD;
39265 Z_scripterrlog("Couldn't create NPC \"%s\", screen NPC limit reached\n", guy_string[id]);
39266 }
39267 else
39268 {
39269 word index = guys.Count() - numcreated; //Get the main enemy, not a segment
39270 ri->guyref = guys.spr(index)->getUID();
39271
39272 for(; index<guys.Count(); index++)
39273 ((enemy*)guys.spr(index))->script_spawned=true;
39274
39275 ri->d[rEXP1] = ri->guyref;
39276 ri->d[rEXP2] = ri->guyref;
39277 Z_eventlog("Script created NPC \"%s\" with UID = %ld\n", guy_string[id], ri->guyref);
39278 }
39279 }
39280
39281 bool FFScript::checkExtension(std::string &filename, const std::string &extension)
39282 //inline bool checkExtension(std::string filename, std::string extension)
39283 {
39284 int32_t dot = filename.find_last_of(".");
39285 std::string exten = (dot == std::string::npos ? "" : filename.substr(dot, filename.length() - dot));
39286 return exten == extension;
39287 }
39288
39289
39290 void FFScript::do_loadgamestructs(const bool v, const bool v2)
39291 {
39292 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
39293 int32_t section_id = SH::get_arg(sarg2, v2) / 10000;
39294 zprint("do_loadgamestructs selected section is: %d\n", section_id);
39295 //Bitwise OR sections together
39296 string strA;
39297 ArrayH::getString(arrayptr, strA, 256);
39298 int32_t temp_sram_flags = section_id; int32_t sram_version = 0;
39299
39300 if ( FFCore.checkExtension(strA, ".zcsram") )
39301 {
39302 PACKFILE *f = pack_fopen_password(strA.c_str(),F_READ, "");
39303 if (f)
39304 {
39305 p_igetl(&sram_version,f);
39306 p_igetl(&section_id,f);
39307 zprint("Reading ZCSRAM, Version: %d\n", sram_version);
39308 if ( sram_version > SRAM_VERSION ) //file version is greater than programme current version.
39309 {
39310 Z_scripterrlog("SRAM Version is from a version of ZC newer than the running version and cannot be loaded.\n");
39311 return;
39312 }
39313 if ( section_id != temp_sram_flags )
39314 {
39315 Z_scripterrlog("Reading an SRAM file with a section flag mismatch!\nThe file section flags are (%d) and the specified flagset is (%d).\nThis may cause errors!\n", section_id, temp_sram_flags);
39316 }
39317
39318 if ( !section_id || section_id&svGUYS ) FFCore.read_enemies(f,sram_version);
39319 if ( !section_id || section_id&svITEMS )FFCore.read_items(f,sram_version);
39320 if ( !section_id || section_id&svWEAPONS ) FFCore.read_weaponsprtites(f,sram_version);
39321 if ( !section_id || section_id&svCOMBOS )
39322 {
39323 reset_combo_animations();
39324 reset_combo_animations2();
39325 FFCore.read_combos(f,sram_version);
39326 }
39327 if ( !section_id || section_id&svDMAPS ) FFCore.read_dmaps(f,sram_version);
39328 if ( !section_id || section_id&svMAPSCR ) FFCore.read_mapscreens(f,sram_version);
39329 pack_fclose(f);
39330 zprint("do_savegamestructs COMPLETED READINV %s, with section ID flags %d\n", "ALL", section_id);
39331
39332 set_register(sarg1, 10000);
39333 }
39334 else
39335 {
39336 Z_scripterrlog("FFCore.do_loadgamestructs could not read packfile!");
39337 set_register(sarg1, -10000);
39338 }
39339 }
39340 else
39341 {
39342 Z_scripterrlog("Tried to read a .zcsram file, but the file lacked the ..zcsram extension!\n");
39343 set_register(sarg1, -20000);
39344
39345 }
39346 }
39347
39348 void FFScript::do_savegamestructs(const bool v, const bool v2)
39349 {
39350 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
39351 int32_t section_id = SH::get_arg(sarg2, v2) / 10000;
39352 zprint("do_loadgamestructs selected section is: %d\n", section_id);
39353 //Bitwise OR sections together
39354 string strA;
39355 ArrayH::getString(arrayptr, strA, 256);
39356 int32_t cycles = 0;
39357
39358 if ( FFCore.checkExtension(strA, ".zcsram") )
39359 {
39360 PACKFILE *f = pack_fopen_password(strA.c_str(),F_WRITE, "");
39361 if (f)
39362 {
39363 p_iputl(SRAM_VERSION,f);
39364 p_iputl(section_id,f);
39365
39366 if ( !section_id || section_id&svGUYS ) FFCore.write_enemies(f,SRAM_VERSION);
39367 if ( !section_id || section_id&svITEMS ) FFCore.write_items(f,SRAM_VERSION);
39368 if ( !section_id || section_id&svWEAPONS ) FFCore.write_weaponsprtites(f,SRAM_VERSION);
39369 if ( !section_id || section_id&svCOMBOS )
39370 {
39371 reset_combo_animations();
39372 reset_combo_animations2();
39373 FFCore.write_combos(f,SRAM_VERSION);
39374 }
39375 if ( !section_id || section_id&svDMAPS ) FFCore.write_dmaps(f,SRAM_VERSION);
39376 if ( !section_id || section_id&svMAPSCR ) FFCore.write_mapscreens(f,SRAM_VERSION);
39377 pack_fclose(f);
39378 zprint("do_savegamestructs COMPLETED WRITING %s, with section ID flags %d\n", "ALL", section_id);
39379 set_register(sarg1, 10000);
39380 }
39381 else
39382 {
39383 Z_scripterrlog("FFCore.do_loadgamestructs could not read packfile!");
39384 set_register(sarg1, -10000);
39385 }
39386 }
39387 else
39388 {
39389 Z_scripterrlog("Tried to write a .zcsram file, but the file lacked the ..zcsram extension!\n");
39390 set_register(sarg1, -20000);
39391 }
39392 }
39393
39394 1 void FFScript::do_strcmp()
39395 {
39396 1 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000 ?
39397 1 int32_t arrayptr_b = ri->d[rINDEX2]/10000; //get_register(sarg2) / 10000?
39398 1 string strA;
39399 1 string strB;
39400
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 ArrayH::getString(arrayptr_a, strA);
39401
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 ArrayH::getString(arrayptr_b, strB);
39402
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 set_register(sarg1, (strcmp(strA.c_str(), strB.c_str()) * 10000));
39403 1 }
39404
39405 void FFScript::do_stricmp()
39406 {
39407 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
39408 int32_t arrayptr_b = ri->d[rINDEX2]/10000; //get_register(sarg2) / 10000?
39409 string strA;
39410 string strB;
39411 ArrayH::getString(arrayptr_a, strA);
39412 ArrayH::getString(arrayptr_b, strB);
39413 set_register(sarg1, (stricmp(strA.c_str(), strB.c_str()) * 10000));
39414 }
39415
39416 1 void FFScript::do_LowerToUpper(const bool v)
39417 {
39418
39419 1 int32_t arrayptr_a = get_register(sarg1) / 10000;
39420 1 string strA;
39421
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 ArrayH::getString(arrayptr_a, strA);
39422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( strA.size() < 1 )
39423 {
39424 Z_scripterrlog("String passed to UpperToLower() is too small. Size is: %d \n", strA.size());
39425 set_register(sarg1, 0); return;
39426 }
39427
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5 times.
6 for ( size_t q = 0; q < strA.size(); ++q )
39428 {
39429
3/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
5 strA[q] -= 32 * (strA[q] >= 'a' && strA[q] <= 'z');
39430 //if(( strA[q] >= 'a' && strA[q] <= 'z' ) || ( strA[q] >= 'A' && strA[q] <= 'Z' ))
39431 //{
39432 // if ( strA[q] < 'a' ) { continue; }
39433 // else strA[q] -= 32;
39434 // continue;
39435 //}
39436
39437 5 }
39438 //zprint("Converted string is: %s \n", strA.c_str());
39439
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
39440 {
39441 Z_scripterrlog("Dest string supplied to 'LowerToUpper()' not large enough\n");
39442 set_register(sarg1, 0);
39443 }
39444
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 else set_register(sarg1, (10000));
39445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 }
39446
39447 void FFScript::do_UpperToLower(const bool v)
39448 {
39449
39450 int32_t arrayptr_a = get_register(sarg1) / 10000;
39451 string strA;
39452 ArrayH::getString(arrayptr_a, strA);
39453 if ( strA.size() < 1 )
39454 {
39455 Z_scripterrlog("String passed to UpperToLower() is too small. Size is: %d \n", strA.size());
39456 set_register(sarg1, 0); return;
39457 }
39458 for ( size_t q = 0; q < strA.size(); ++q )
39459 {
39460 strA[q] += 32 * (strA[q] >= 'A' && strA[q] <= 'Z');
39461 //if(( strA[q] >= 'a' && strA[q] <= 'z' ) || ( strA[q] >= 'A' && strA[q] <= 'Z' ))
39462 //{
39463 // if ( strA[q] < 'a' ) { strA[q] += 32; }
39464 // else continue;
39465 // continue;
39466 //}
39467 }
39468 //zprint("Converted string is: %s \n", strA.c_str());
39469 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
39470 {
39471 Z_scripterrlog("Dest string supplied to 'LowerToUpper()' not large enough\n");
39472 set_register(sarg1, 0);
39473 }
39474 else set_register(sarg1, (10000));
39475 }
39476
39477 void FFScript::do_getnpcscript()
39478 {
39479 int32_t arrayptr = get_register(sarg1) / 10000;
39480 string the_string;
39481 int32_t script_num = -1;
39482 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39483
39484 for(int32_t q = 0; q < NUMSCRIPTGUYS; q++)
39485 {
39486 if(!(strcmp(the_string.c_str(), npcmap[q].scriptname.c_str())))
39487 {
39488 script_num = q+1;
39489 break;
39490 }
39491 }
39492 set_register(sarg1, (script_num * 10000));
39493 }
39494
39495 void FFScript::do_getcomboscript()
39496 {
39497 int32_t arrayptr = get_register(sarg1) / 10000;
39498 string the_string;
39499 int32_t script_num = -1;
39500 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39501
39502 for(int32_t q = 0; q < NUMSCRIPTSCOMBODATA; q++)
39503 {
39504 if(!(strcmp(the_string.c_str(), comboscriptmap[q].scriptname.c_str())))
39505 {
39506 script_num = q+1;
39507 break;
39508 }
39509 }
39510 set_register(sarg1, (script_num * 10000));
39511 }
39512
39513 68 void FFScript::do_getgenericscript()
39514 {
39515 68 int32_t arrayptr = get_register(sarg1) / 10000;
39516 68 string the_string;
39517 68 int32_t script_num = -1;
39518
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39519
39520 // zprint2("Searching for generic script named '%s'\n", the_string.c_str());
39521
1/2
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
361 for(int32_t q = 0; q < NUMSCRIPTSGENERIC; q++)
39522 {
39523 // if(genericmap[q].scriptname.size()>2)
39524 // zprint2("Checking against '%s'...\n", genericmap[q].scriptname.c_str());
39525
3/4
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 68 times.
361 if(!(strcmp(the_string.c_str(), genericmap[q].scriptname.c_str())))
39526 {
39527 68 script_num = q+1;
39528 68 break;
39529 }
39530 293 }
39531
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 set_register(sarg1, (script_num * 10000));
39532 68 }
39533
39534 602 void FFScript::do_getlweaponscript()
39535 {
39536 602 int32_t arrayptr = get_register(sarg1) / 10000;
39537 602 string the_string;
39538 602 int32_t script_num = -1;
39539
1/2
✓ Branch 0 taken 602 times.
✗ Branch 1 not taken.
602 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39540
39541
1/2
✓ Branch 0 taken 17373 times.
✗ Branch 1 not taken.
17373 for(int32_t q = 0; q < NUMSCRIPTWEAPONS; q++)
39542 {
39543
3/4
✓ Branch 0 taken 17373 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16771 times.
✓ Branch 3 taken 602 times.
17373 if(!(strcmp(the_string.c_str(), lwpnmap[q].scriptname.c_str())))
39544 {
39545 602 script_num = q+1;
39546 602 break;
39547 }
39548 16771 }
39549
1/2
✓ Branch 0 taken 602 times.
✗ Branch 1 not taken.
602 set_register(sarg1, (script_num * 10000));
39550 602 }
39551 1275 void FFScript::do_geteweaponscript()
39552 {
39553 1275 int32_t arrayptr = get_register(sarg1) / 10000;
39554 1275 string the_string;
39555 1275 int32_t script_num = -1;
39556
1/2
✓ Branch 0 taken 1275 times.
✗ Branch 1 not taken.
1275 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39557
39558
1/2
✓ Branch 0 taken 29109 times.
✗ Branch 1 not taken.
29109 for(int32_t q = 0; q < NUMSCRIPTWEAPONS; q++)
39559 {
39560
3/4
✓ Branch 0 taken 29109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27834 times.
✓ Branch 3 taken 1275 times.
29109 if(!(strcmp(the_string.c_str(), ewpnmap[q].scriptname.c_str())))
39561 {
39562 1275 script_num = q+1;
39563 1275 break;
39564 }
39565 27834 }
39566
1/2
✓ Branch 0 taken 1275 times.
✗ Branch 1 not taken.
1275 set_register(sarg1, (script_num * 10000));
39567 1275 }
39568 void FFScript::do_getheroscript()
39569 {
39570 int32_t arrayptr = get_register(sarg1) / 10000;
39571 string the_string;
39572 int32_t script_num = -1;
39573 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39574
39575 for(int32_t q = 0; q < NUMSCRIPTPLAYER; q++)
39576 {
39577 if(!(strcmp(the_string.c_str(), playermap[q].scriptname.c_str())))
39578 {
39579 script_num = q+1;
39580 break;
39581 }
39582 }
39583 set_register(sarg1, (script_num * 10000));
39584 }
39585 void FFScript::do_getglobalscript()
39586 {
39587 int32_t arrayptr = get_register(sarg1) / 10000;
39588 string the_string;
39589 int32_t script_num = -1;
39590 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39591
39592 for(int32_t q = 0; q < NUMSCRIPTGLOBAL; q++)
39593 {
39594 if(!(strcmp(the_string.c_str(), globalmap[q].scriptname.c_str())))
39595 {
39596 script_num = q+1;
39597 break;
39598 }
39599 }
39600 set_register(sarg1, (script_num * 10000));
39601 }
39602 105 void FFScript::do_getdmapscript()
39603 {
39604 105 int32_t arrayptr = get_register(sarg1) / 10000;
39605 105 string the_string;
39606 105 int32_t script_num = -1;
39607
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39608
39609
1/2
✓ Branch 0 taken 590 times.
✗ Branch 1 not taken.
590 for(int32_t q = 0; q < NUMSCRIPTSDMAP; q++)
39610 {
39611
3/4
✓ Branch 0 taken 590 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 485 times.
✓ Branch 3 taken 105 times.
590 if(!(strcmp(the_string.c_str(), dmapmap[q].scriptname.c_str())))
39612 {
39613 105 script_num = q+1;
39614 105 break;
39615 }
39616 485 }
39617
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 set_register(sarg1, (script_num * 10000));
39618 105 }
39619 void FFScript::do_getscreenscript()
39620 {
39621 int32_t arrayptr = get_register(sarg1) / 10000;
39622 string the_string;
39623 int32_t script_num = -1;
39624 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39625
39626 for(int32_t q = 0; q < NUMSCRIPTSCREEN; q++)
39627 {
39628 if(!(strcmp(the_string.c_str(), screenmap[q].scriptname.c_str())))
39629 {
39630 script_num = q+1;
39631 break;
39632 }
39633 }
39634 set_register(sarg1, (script_num * 10000));
39635 }
39636 31 void FFScript::do_getitemspritescript()
39637 {
39638 31 int32_t arrayptr = get_register(sarg1) / 10000;
39639 31 string the_string;
39640 31 int32_t script_num = -1;
39641
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39642
39643
1/2
✓ Branch 0 taken 273 times.
✗ Branch 1 not taken.
273 for(int32_t q = 0; q < NUMSCRIPTSITEMSPRITE; q++)
39644 {
39645
3/4
✓ Branch 0 taken 273 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242 times.
✓ Branch 3 taken 31 times.
273 if(!(strcmp(the_string.c_str(), itemspritemap[q].scriptname.c_str())))
39646 {
39647 31 script_num = q+1;
39648 31 break;
39649 }
39650 242 }
39651
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 set_register(sarg1, (script_num * 10000));
39652 31 }
39653 //Not assigned to slots at present. If they ever are, then this would get the id of any script (any type) by name. -Z
39654 void FFScript::do_getuntypedscript()
39655 {
39656 set_register(sarg1, 0);
39657 //int32_t arrayptr = ri->d[rINDEX]/10000;
39658 //string the_string;
39659 //int32_t script_num = -1;
39660 //ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39661
39662 //for(int32_t q = 0; q < NUMSCRIPTSITEMSPRITE; q++)
39663 //{
39664 // if(!(strcmp(the_string.c_str(), itemspritemap[q].scriptname.c_str())))
39665 // {
39666 // script_num = q+1;
39667 // break;
39668 // }
39669 //}
39670 //set_register(sarg1, (script_num * 10000));
39671 }
39672 void FFScript::do_getsubscreenscript()
39673 {
39674 //int32_t arrayptr = ri->d[rINDEX]/10000;
39675 //string the_string;
39676 //int32_t script_num = -1;
39677 //ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39678
39679 //for(int32_t q = 0; q < NUMSCRIPTSUBSCREEN; q++)
39680 //{
39681 // if(!(strcmp(the_string.c_str(), subscreenmap[q].scriptname.c_str())))
39682 // {
39683 // script_num = q+1;
39684 // break;
39685 // }
39686 //}
39687 //set_register(sarg1, (script_num * 10000));
39688 set_register(sarg1, 0); //Remove this line, when we add this script type, then un-comment the rest. -Z
39689 }
39690 void FFScript::do_getnpcbyname()
39691 {
39692 int32_t arrayptr = get_register(sarg1) / 10000;
39693 string the_string;
39694 int32_t num = -1;
39695 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39696
39697 for(int32_t q = 0; q < MAXNPCS; q++)
39698 {
39699 if(!(strcmp(the_string.c_str(), guy_string[q])))
39700 {
39701 num = q;
39702 break;
39703 }
39704 }
39705 set_register(sarg1, (num * 10000));
39706 }
39707 void FFScript::do_getitembyname()
39708 {
39709 int32_t arrayptr = get_register(sarg1) / 10000;
39710 string the_string;
39711 int32_t num = -1;
39712 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39713
39714 for(int32_t q = 0; q < MAXNPCS; q++)
39715 {
39716 if(!(strcmp(the_string.c_str(), item_string[q])))
39717 {
39718 num = q;
39719 break;
39720 }
39721 }
39722 set_register(sarg1, (num * 10000));
39723 }
39724 void FFScript::do_getcombobyname()
39725 {
39726 int32_t arrayptr = get_register(sarg1) / 10000;
39727 string the_string;
39728 int32_t num = -1;
39729 ArrayH::getString(arrayptr, the_string, 256);
39730
39731 if (!the_string.empty())
39732 {
39733 for(int32_t q = 0; q < MAXCOMBOS; q++)
39734 {
39735 if (the_string == combobuf[q].label)
39736 {
39737 num = q;
39738 break;
39739 }
39740 }
39741 }
39742 set_register(sarg1, (num * 10000));
39743 }
39744 void FFScript::do_getdmapbyname()
39745 {
39746 int32_t arrayptr = get_register(sarg1) / 10000;
39747 string the_string;
39748 int32_t num = -1;
39749 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39750
39751 for(int32_t q = 0; q < MAXNPCS; q++)
39752 {
39753 if(!(strcmp(the_string.c_str(), DMaps[q].title)))
39754 {
39755 num = q;
39756 break;
39757 }
39758 }
39759 set_register(sarg1, (num * 10000));
39760 }
39761
39762 ////////////////////////
39763 /// String Utilities ///
39764 ////////////////////////
39765 void FFScript::do_ConvertCase(const bool v)
39766 {
39767 int32_t arrayptr_a = get_register(sarg1) / 10000;
39768 string strA;
39769 ArrayH::getString(arrayptr_a, strA);
39770 if ( strA.size() < 1 )
39771 {
39772 Z_scripterrlog("String passed to UpperToLower() is too small. Size is: %d \n", strA.size());
39773 set_register(sarg1, 0); return;
39774 }
39775 for ( size_t q = 0; q < strA.size(); ++q )
39776 {
39777 if ( strA[q] < 'a' )
39778 strA[q] += 32 * (strA[q] >= 'A' && strA[q] <= 'Z');
39779
39780 else
39781 strA[q] -= 32 * (strA[q] >= 'a' && strA[q] <= 'z');
39782 //strA[q] -= (32 * (strA[q] >= 'a' && strA[q] <= 'z')) * (-1*((strA[q] >= 'A' && strA[q] <= 'Z')));
39783 //int32_t n = 'c';
39784
39785 //strA[q] -= 32 * ((strA[q] >= 'a' && strA[q] <= 'z')) * (-1*((strA[q] >= 'A' && strA[q] <= 'Z')));
39786 //zprint2("n is %d\n", n);
39787 //if(( strA[q] >= 'a' || strA[q] <= 'z' ) || ( strA[q] >= 'A' || strA[q] <= 'Z' ))
39788 //{
39789 // if ( strA[q] < 'a' ) { strA[q] += 32; }
39790 // else strA[q] -= 32;
39791 // continue;
39792 //}
39793
39794 }
39795 //zprint("Converted string is: %s \n", strA.c_str());
39796 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
39797 {
39798 Z_scripterrlog("Dest string supplied to 'LowerToUpper()' not large enough\n");
39799 set_register(sarg1, 0);
39800 }
39801 else set_register(sarg1, (10000));
39802 }
39803
39804 void FFScript::do_xlen(const bool v)
39805 {
39806 //not implemented, xlen not found
39807 //zprint("Running: %s\n","strlen()");
39808 int32_t arrayptr = (SH::get_arg(sarg2, v) / 10000);
39809 string str;
39810 ArrayH::getString(arrayptr, str);
39811 //zprint("strlen string size is: %d\n", str.length());
39812 //set_register(sarg1, (xlen(str.c_str()) * 10000));
39813 }
39814
39815 void FFScript::do_xtoi(const bool v)
39816 {
39817 int32_t arrayptr = (SH::get_arg(sarg2, v) / 10000);
39818 string str;
39819 ArrayH::getString(arrayptr, str);
39820 //zprint2("xtoi array pointer is: %d\n", arrayptr);
39821 //zprint2("xtoi string is %s\n", str.c_str());
39822 double val = zc_xtoi(const_cast<char*>(str.c_str()));
39823 //zprint2("xtoi val is %f\n", val);
39824 set_register(sarg1, (int32_t)(val) * 10000);
39825 }
39826 void FFScript::do_xtoi2()
39827 {
39828 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
39829 string strA;
39830 ArrayH::getString(arrayptr_a, strA);
39831 set_register(sarg1, (zc_xtoi(strA.c_str()) * 10000));
39832 }
39833
39834 // Calculates log2 of number.
39835 double FFScript::Log2( double n )
39836 {
39837 // log(n)/log(2) is log2.
39838 return log( (double)n ) / log( (double)2 );
39839 }
39840
39841 //xtoa, convert hex number to hex ascii
39842 void FFScript::do_xtoa()
39843 {
39844
39845 int32_t arrayptr_a = get_register(sarg1) / 10000;
39846 int32_t number = get_register(sarg2) / 10000;//ri->d[rEXP2]/10000; //why are you not in sarg2?!!
39847
39848 //for ( int32_t q = 0; q < 6; ++q )
39849 // zprint2("ri->d[%d] is %d", q, ri->d[q]);
39850
39851 // zprint2("xtoa_c arrayptr_a is: %d\n",arrayptr_a);
39852 // zprint2("xtoa_c number is: %d\n",number);
39853
39854
39855
39856
39857 bool isneg = false;
39858 if ( number < 0 )
39859 {
39860 isneg = true;
39861 number *= -1;
39862 }
39863 double num = number;
39864 // zprint2("xtoa_c(), num is: %f\n", num);
39865 int32_t digits = num ? floor(FFCore.LogToBase(num, 16) + 1) : 1;
39866 //sizeof(number)*CHAR_BIT/4;
39867 // zprint2("xtoa_c, digits is: %d\n",digits);
39868
39869
39870 int32_t pos = 0;
39871 string strA;
39872 if(number == 0) //Needs to precede str.resize(digits+3) as if the number is <= 0 then this breaks.
39873 {
39874 strA.resize(3);
39875 strA[pos+2] = '0';
39876 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
39877 {
39878 Z_scripterrlog("Dest string supplied to 'itoa()' not large enough\n");
39879 set_register(sarg1, 0);
39880 }
39881 else set_register(sarg1, 30000); //returns the pointer to the dest
39882 return;
39883 }
39884 int32_t ret = 0;
39885 strA.resize(digits+3+(isneg?1:0));
39886 //num = Floor(Abs(num));
39887 if ( isneg )
39888 {
39889 strA[pos] = '-';
39890 strA[pos+1] = '0';
39891 strA[pos+2] = 'x';
39892 ret = 3;
39893 }
39894 else
39895 {
39896 strA[pos] = '0';
39897 strA[pos+1] = 'x';
39898 ret = 2;
39899 }
39900
39901 int32_t alphaoffset = 'A' - 0xA;
39902 for(int32_t i = 0; i < digits; ++i)
39903 {
39904 int32_t coeff = ((int32_t)floor((double)(((double)number) / pow((float)0x10, digits - i - 1))) % 0x10);
39905 strA[pos + ret + i] = coeff < 0xA ? coeff + '0' : coeff + alphaoffset;
39906 }
39907 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
39908 {
39909 Z_scripterrlog("Dest string supplied to 'xtoa()' not large enough\n");
39910 set_register(sarg1, 0);
39911 }
39912 //set_register(sarg1, (strcat((char)strA.c_str(), strB.c_str()) * 10000));
39913 else set_register(sarg1, (ret + digits -(isneg?1:0))*10000); //don't count the - sign as a digit
39914 }
39915
39916 void FFScript::do_ilen(const bool v)
39917 {
39918 int32_t arrayptr = (SH::get_arg(sarg2, v) / 10000);
39919 string str;
39920 ArrayH::getString(arrayptr, str);
39921 //zprint("strlen string size is: %d\n", str.length());
39922 set_register(sarg1, (FFCore.ilen((char*)str.c_str()) * 10000));
39923 }
39924
39925 //! Note atoi2 (atoi(str, len) can be accompished with str.resize after getString.
39926 void FFScript::do_atoi(const bool v)
39927 {
39928 int32_t arrayptr = (SH::get_arg(sarg2, v) / 10000);
39929 string str;
39930 ArrayH::getString(arrayptr, str);
39931 set_register(sarg1, (atoi(str.c_str()) * 10000));
39932 }
39933
39934 void FFScript::do_strstr()
39935 {
39936
39937 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
39938 int32_t arrayptr_b = ri->d[rINDEX2]/10000; //get_register(sarg2) / 10000?
39939 string strA;
39940 string strB;
39941 ArrayH::getString(arrayptr_a, strA);
39942 ArrayH::getString(arrayptr_b, strB);
39943 if ( strA.size() < 1 )
39944 {
39945 Z_scripterrlog("String passed to strstr() is too small. Size is: %d \n", strA.size());
39946 set_register(sarg1,-10000);
39947 return;
39948 }
39949 set_register(sarg1, (strA.find(strB) * 10000));
39950 }
39951
39952 void FFScript::do_strcat()
39953 {
39954
39955 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
39956 int32_t arrayptr_b = ri->d[rINDEX2]/10000; //get_register(sarg2) / 10000?
39957 string strA;
39958 string strB;
39959 ArrayH::getString(arrayptr_a, strA);
39960 ArrayH::getString(arrayptr_b, strB);
39961 //char str_c[2048];
39962 //strcpy(str_c, strA.c_str());
39963 string strC = strA + strB;
39964 //zprint("strcat string: %s\n", strC.c_str());
39965 if(ArrayH::setArray(arrayptr_a, strC) == SH::_Overflow)
39966 {
39967 Z_scripterrlog("Dest string supplied to 'strcat()' not large enough\n");
39968 set_register(sarg1, 0);
39969 }
39970 //set_register(sarg1, (strcat((char)strA.c_str(), strB.c_str()) * 10000));
39971 else set_register(sarg1, arrayptr_a); //returns the pointer to the dest
39972 }
39973 void FFScript::do_strspn()
39974 {
39975
39976 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
39977 int32_t arrayptr_b = ri->d[rINDEX2]/10000; //get_register(sarg2) / 10000?
39978 string strA;
39979 string strB;
39980 ArrayH::getString(arrayptr_a, strA);
39981 ArrayH::getString(arrayptr_b, strB);
39982 set_register(sarg1, (strspn(strA.c_str(), strB.c_str()) * 10000));
39983 }
39984
39985 void FFScript::do_strcspn()
39986 {
39987
39988 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
39989 int32_t arrayptr_b = ri->d[rINDEX2]/10000;
39990 string strA;
39991 string strB;
39992 ArrayH::getString(arrayptr_a, strA);
39993 ArrayH::getString(arrayptr_b, strB);
39994 set_register(sarg1, (strcspn(strA.c_str(), strB.c_str()) * 10000));
39995 }
39996
39997 void FFScript::do_strchr()
39998 {
39999
40000 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
40001 char chr_to_find = (ri->d[rINDEX2]/10000);
40002 string strA;
40003 ArrayH::getString(arrayptr_a, strA);
40004 if ( strA.size() < 1 )
40005 {
40006 Z_scripterrlog("String passed to strchr() is too small. Size is: %d \n", strA.size());
40007 set_register(sarg1,-10000);
40008 return;
40009 }
40010
40011 set_register(sarg1,strA.find_first_of(chr_to_find)*10000);
40012 }
40013 void FFScript::do_strrchr()
40014 {
40015 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
40016 char chr_to_find = (ri->d[rINDEX2]/10000);
40017 string strA;
40018 ArrayH::getString(arrayptr_a, strA);
40019 if ( strA.size() < 1 )
40020 {
40021 Z_scripterrlog("String passed to strrchr() is too small. Size is: %d \n", strA.size());
40022 set_register(sarg1,-10000);
40023 return;
40024 }
40025 set_register(sarg1,strA.find_last_of(chr_to_find)*10000);
40026 }
40027
40028 void FFScript::do_remchr2()
40029 {
40030 //Not implemented, remchr not found
40031 //not part of any standard library
40032 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
40033 string strA;
40034 ArrayH::getString(arrayptr_a, strA);
40035 //set_register(sarg1, (remchr(strA.c_str(), (ri->d[rINDEX2]/10000)) * 10000));
40036 }
40037 //Bookmark
40038 void FFScript::do_atoi2()
40039 {
40040 //not implemented; atoi does not take 2 params
40041 int32_t arrayptr_a = ri->d[rINDEX]/10000;
40042 string strA;
40043 ArrayH::getString(arrayptr_a, strA);
40044 //set_register(sarg1, (atoi(strA.c_str(), (ri->d[rINDEX2]/10000)) * 10000));
40045 }
40046 void FFScript::do_ilen2()
40047 {
40048 //not implemented, ilen not found
40049 int32_t arrayptr_a = ri->d[rINDEX]/10000;
40050 string strA;
40051 ArrayH::getString(arrayptr_a, strA);
40052 //set_register(sarg1, (ilen(strA.c_str(), (ri->d[rINDEX2]/10000)) * 10000));
40053 }
40054 void FFScript::do_xlen2()
40055 {
40056 //not implemented, xlen not found
40057 int32_t arrayptr_a = ri->d[rINDEX]/10000;
40058 string strA;
40059 ArrayH::getString(arrayptr_a, strA);
40060 //set_register(sarg1, (xlen(strA.c_str(), (ri->d[rINDEX2]/10000)) * 10000));
40061 }
40062
40063 4761 void FFScript::do_itoa()
40064 {
40065 4761 int32_t arrayptr_a = get_register(sarg1) / 10000;
40066 4761 int32_t number = get_register(sarg2) / 10000;
40067
40068 char buf[16];
40069 4761 zc_itoa(number, buf, 10);
40070 4761 int32_t ret = ::strlen(buf) * 10000L;
40071
1/2
✓ Branch 0 taken 4761 times.
✗ Branch 1 not taken.
4761 string strA(buf);
40072
40073
2/4
✓ Branch 0 taken 4761 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4761 times.
4761 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
40074 {
40075 Z_scripterrlog("Dest string supplied to 'itoa()' not large enough\n");
40076 set_register(sarg1, -1);
40077 }
40078
1/2
✓ Branch 0 taken 4761 times.
✗ Branch 1 not taken.
4761 else set_register(sarg1, ret); //returns the number of digits used
40079 4761 }
40080
40081 void FFScript::do_itoacat()
40082 {
40083
40084 int32_t arrayptr_a = get_register(sarg1) / 10000;
40085 int32_t number = get_register(sarg2) / 10000;
40086
40087 // zprint2("itoacat arrayptr_a is: %d\n",arrayptr_a);
40088 // zprint2("itoacat number is: %d\n",number);
40089
40090 double num = number;
40091 int32_t digits = FFCore.numDigits(number); //int32_t(log10(temp) * 10000.0)
40092 // zprint2("itoacat, digits is: %d\n",digits);
40093 int32_t pos = 0;
40094 int32_t ret = 0;
40095 string strA;
40096 string strB;
40097 strB.resize(digits);
40098 ArrayH::getString(arrayptr_a, strA);
40099 if(num < 0)
40100 {
40101 strB.resize(digits+1);
40102 strB[pos] = '-';
40103 ++ret;
40104 num = -num;
40105 }
40106 else if(num == 0)
40107 {
40108 strB[pos] = '0';
40109 string strC = strA + strB;
40110 if(ArrayH::setArray(arrayptr_a, strC) == SH::_Overflow)
40111 {
40112 Z_scripterrlog("Dest string supplied to 'itoacat()' not large enough\n");
40113 set_register(sarg1, 0);
40114 }
40115 else set_register(sarg1, arrayptr_a); //returns the pointer to the dest
40116 return;
40117 }
40118
40119
40120 for(int32_t i = 0; i < digits; ++i)
40121 strB[pos + ret + i] = ((int32_t)floor((double)(num / pow((float)10, digits - i - 1))) % 10) + '0';
40122
40123 string strC = strA + strB;
40124 if(ArrayH::setArray(arrayptr_a, strC) == SH::_Overflow)
40125 {
40126 Z_scripterrlog("Dest string supplied to 'itoacat()' not large enough\n");
40127 set_register(sarg1, 0);
40128 }
40129 //set_register(sarg1, (strcat((char)strB.c_str(), strB.c_str()) * 10000));
40130 else set_register(sarg1, arrayptr_a); //returns the pointer to the dest
40131 }
40132
40133 /*
40134 void FFScript::do_itoa()
40135 {
40136
40137 int32_t arrayptr_a = ri->d[rINDEX2]/10000;
40138 int32_t value = ri->d[rINDEX]/10000;
40139 char the_string[13];
40140 char* chrptr = NULL;
40141 chrptr = zc_itoa(value, the_string, 10);
40142 //Returns the number of characters used.
40143 if(ArrayH::setArray(arrayptr_a, the_string) == SH::_Overflow)
40144 Z_scripterrlog("Dest string supplied to 'itoa()' not large enough\n");
40145 set_register(sarg1, (FFCore.zc_strlen(the_string)*10000));
40146 }
40147 */
40148
40149 1072 void FFScript::do_strcpy(const bool a, const bool b)
40150 {
40151 1072 int32_t arrayptr_b = SH::get_arg(sarg1, a) / 10000;
40152 1072 int32_t arrayptr_a = SH::get_arg(sarg2, b) / 10000;
40153
40154 1072 string strA;
40155
40156
1/2
✓ Branch 0 taken 1072 times.
✗ Branch 1 not taken.
1072 ArrayH::getString(arrayptr_a, strA);
40157
40158
2/4
✓ Branch 0 taken 1072 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1072 times.
1072 if(ArrayH::setArray(arrayptr_b, strA) == SH::_Overflow)
40159 Z_scripterrlog("Dest string supplied to 'strcpy()' not large enough\n");
40160 1072 }
40161 void FFScript::do_arraycpy(const bool a, const bool b)
40162 {
40163 int32_t arrayptr_dest = SH::get_arg(sarg1, a) / 10000;
40164 int32_t arrayptr_src = SH::get_arg(sarg2, b) / 10000;
40165 ArrayH::copyValues(arrayptr_dest, arrayptr_src, ArrayH::getSize(arrayptr_src));
40166 }
40167 2629 void FFScript::do_strlen(const bool v)
40168 {
40169 //zprint("Running: %s\n","strlen()");
40170 2629 int32_t arrayptr = (SH::get_arg(sarg2, v) / 10000);
40171 2629 string str;
40172
1/2
✓ Branch 0 taken 2629 times.
✗ Branch 1 not taken.
2629 ArrayH::getString(arrayptr, str);
40173 //zprint("strlen string size is: %d\n", str.length());
40174
1/2
✓ Branch 0 taken 2629 times.
✗ Branch 1 not taken.
2629 set_register(sarg1, (str.length() * 10000));
40175 2629 }
40176
40177 void FFScript::do_strncmp()
40178 {
40179 int32_t arrayptr_a = ri->d[rINDEX]/10000;
40180 int32_t arrayptr_b = ri->d[rEXP2]/10000;
40181 int32_t len = ri->d[rEXP1]/10000;
40182 string strA;
40183 string strB;
40184 ArrayH::getString(arrayptr_a, strA);
40185 ArrayH::getString(arrayptr_b, strB);
40186 set_register(sarg1, (strncmp(strA.c_str(), strB.c_str(), len) * 10000));
40187 }
40188
40189 void FFScript::do_strnicmp()
40190 {
40191 int32_t arrayptr_a = ri->d[rINDEX]/10000;
40192 int32_t arrayptr_b = ri->d[rEXP2]/10000;
40193 int32_t len = ri->d[rEXP1]/10000;
40194 string strA;
40195 string strB;
40196 ArrayH::getString(arrayptr_a, strA);
40197 ArrayH::getString(arrayptr_b, strB);
40198 set_register(sarg1, (ustrnicmp(strA.c_str(), strB.c_str(), len) * 10000));
40199 }
40200
40201 void FFScript::do_npc_canmove(const bool v)
40202 {
40203 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
40204 int32_t sz = ArrayH::getSize(arrayptr);
40205 //bool can_mv = false;
40206 if(GuyH::loadNPC(ri->guyref, "npc->CanMove()") == SH::_NoError)
40207 {
40208 ArrayManager am(arrayptr);
40209 if(am.invalid()) return;
40210 if ( sz == 1 ) //bool canmove(int32_t ndir): dir only, uses 'step' IIRC
40211 {
40212 set_register(sarg1, ( GuyH::getNPC()->canmove((am.get(0)/10000),false)) ? 10000 : 0);
40213 }
40214 else if ( sz == 2 ) //bool canmove(int32_t ndir, int32_t special): I think that this also uses the default 'step'
40215 {
40216 set_register(sarg1, ( GuyH::getNPC()->canmove((am.get(0)/10000),(zfix)(am.get(1)/10000), false)) ? 10000 : 0);
40217 }
40218 else if ( sz == 3 ) //bool canmove(int32_t ndir,zfix s,int32_t special) : I'm pretty sure that 'zfix s' is 'step' here.
40219 {
40220 set_register(sarg1, ( GuyH::getNPC()->canmove((am.get(0)/10000),(zfix)(am.get(1)/10000),(am.get(2)/10000),false)) ? 10000 : 0);
40221 }
40222 else if ( sz == 7 ) //bool canmove(int32_t ndir,zfix s,int32_t special) : I'm pretty sure that 'zfix s' is 'step' here.
40223 {
40224 set_register(sarg1, ( GuyH::getNPC()->canmove((am.get(0)/10000),(zfix)(am.get(1)/10000),(am.get(2)/10000),(am.get(3)/10000),(am.get(4)/10000),(am.get(5)/10000),(am.get(6)/10000),false)) ? 10000 : 0);
40225 }
40226 else
40227 {
40228 Z_scripterrlog("Invalid array size (%d) passed to npc->CanMove(). The array size must be [1], [2], [3], or [7].\n", sz);
40229 //can_mv = false;
40230 set_register(sarg1, 0);
40231 }
40232 }
40233 //set_register(sarg1, ( can_mv ? 10000 : 0));
40234 }
40235
40236 //void do_get_enh_music_filename(const bool v)
40237 void FFScript::get_npcdata_initd_label(const bool v)
40238 {
40239 int32_t init_d_index = SH::get_arg(sarg1, v) / 10000;
40240 int32_t arrayptr = get_register(sarg2) / 10000;
40241
40242 if((unsigned)init_d_index > 7)
40243 {
40244 Z_scripterrlog("Invalid InitD[] index (%d) passed to npcdata->GetInitDLabel().\n", init_d_index);
40245 return;
40246 }
40247
40248 if(ArrayH::setArray(arrayptr, string(guysbuf[ri->npcdataref].initD_label[init_d_index])) == SH::_Overflow)
40249 Z_scripterrlog("Array supplied to 'npcdata->GetInitDLabel()' not large enough\n");
40250 }
40251
40252 /////////////////////
40253 /// MATHS HELPERS ///
40254 /////////////////////
40255
40256 //Returns the log of val to the base 10. Any value <= 0 will return 0.
40257 int32_t FFScript::Log10(double temp)
40258 {
40259 int32_t ret = 0;
40260 if(temp > 0)
40261 ret = int32_t(log10(temp) * 10000.0);
40262 else ret = 0;
40263 return ret;
40264 }
40265
40266 //Returns the number of digits in a given integer.
40267 int32_t FFScript::numDigits(int32_t number)
40268 {
40269 int32_t digits = 0;
40270 while (number)
40271 {
40272 number /= 10;
40273 digits++;
40274 }
40275 return digits;
40276 }
40277
40278 // Returns the natural logarithm of val (to the base e). Any value <= 0 will return 0.
40279 double FFScript::ln(double temp)
40280 {
40281
40282 if(temp > 0)
40283 return (log(temp));
40284 else
40285 {
40286 return 0;
40287 }
40288 }
40289
40290 // Returns the logarithm of x to the given base.
40291 double FFScript::LogToBase(double x, double base)
40292 {
40293 if(x <= 0 || base <= 0) return 0;
40294 return FFCore.ln(x)/FFCore.ln(base);
40295 }
40296
40297 script_command ZASMcommands[NUMCOMMANDS+1]=
40298 {
40299 //name args arg1 arg2 more
40300 { "SETV", 2, 0, 1, 0},
40301 { "SETR", 2, 0, 0, 0},
40302 { "ADDR", 2, 0, 0, 0},
40303 { "ADDV", 2, 0, 1, 0},
40304 { "SUBR", 2, 0, 0, 0},
40305 { "SUBV", 2, 0, 1, 0},
40306 { "MULTR", 2, 0, 0, 0},
40307 { "MULTV", 2, 0, 1, 0},
40308 { "DIVR", 2, 0, 0, 0},
40309 { "DIVV", 2, 0, 1, 0},
40310 { "WAITFRAME", 0, 0, 0, 0},
40311 { "GOTO", 1, 1, 0, 0},
40312 { "CHECKTRIG", 0, 0, 0, 0},
40313 { "WARP", 2, 1, 1, 0},
40314 { "COMPARER", 2, 0, 0, 0},
40315 { "COMPAREV", 2, 0, 1, 0},
40316 { "GOTOTRUE", 1, 1, 0, 0},
40317 { "GOTOFALSE", 1, 1, 0, 0},
40318 { "GOTOLESS", 1, 1, 0, 0},
40319 { "GOTOMORE", 1, 1, 0, 0},
40320 { "LOAD1", 2, 0, 0, 0},
40321 { "LOAD2", 2, 0, 0, 0},
40322 { "SETA1", 2, 0, 0, 0},
40323 { "SETA2", 2, 0, 0, 0},
40324 { "QUIT", 0, 0, 0, 0},
40325 { "SINR", 2, 0, 0, 0},
40326 { "SINV", 2, 0, 1, 0},
40327 { "COSR", 2, 0, 0, 0},
40328 { "COSV", 2, 0, 1, 0},
40329 { "TANR", 2, 0, 0, 0},
40330 { "TANV", 2, 0, 1, 0},
40331 { "MODR", 2, 0, 0, 0},
40332 { "MODV", 2, 0, 1, 0},
40333 { "ABS", 1, 0, 0, 0},
40334 { "MINR", 2, 0, 0, 0},
40335 { "MINV", 2, 0, 1, 0},
40336 { "MAXR", 2, 0, 0, 0},
40337 { "MAXV", 2, 0, 1, 0},
40338 { "RNDR", 2, 0, 0, 0},
40339 { "RNDV", 2, 0, 1, 0},
40340 { "FACTORIAL", 1, 0, 0, 0},
40341 { "POWERR", 2, 0, 0, 0},
40342 { "POWERV", 2, 0, 1, 0},
40343 { "IPOWERR", 2, 0, 0, 0},
40344 { "IPOWERV", 2, 0, 1, 0},
40345 { "ANDR", 2, 0, 0, 0},
40346 { "ANDV", 2, 0, 1, 0},
40347 { "ORR", 2, 0, 0, 0},
40348 { "ORV", 2, 0, 1, 0},
40349 { "XORR", 2, 0, 0, 0},
40350 { "XORV", 2, 0, 1, 0},
40351 { "NANDR", 2, 0, 0, 0},
40352 { "NANDV", 2, 0, 1, 0},
40353 { "NORR", 2, 0, 0, 0},
40354 { "NORV", 2, 0, 1, 0},
40355 { "XNORR", 2, 0, 0, 0},
40356 { "XNORV", 2, 0, 1, 0},
40357 { "NOT", 1, 0, 0, 0},
40358 { "LSHIFTR", 2, 0, 0, 0},
40359 { "LSHIFTV", 2, 0, 1, 0},
40360 { "RSHIFTR", 2, 0, 0, 0},
40361 { "RSHIFTV", 2, 0, 1, 0},
40362 { "TRACER", 1, 0, 0, 0},
40363 { "TRACEV", 1, 1, 0, 0},
40364 { "TRACE3", 0, 0, 0, 0},
40365 { "LOOP", 2, 1, 0, 0},
40366 { "PUSHR", 1, 0, 0, 0},
40367 { "PUSHV", 1, 1, 0, 0},
40368 { "POP", 1, 0, 0, 0},
40369 { "ENQUEUER", 2, 0, 0, 0},
40370 { "ENQUEUEV", 2, 0, 1, 0},
40371 { "DEQUEUE", 1, 0, 0, 0},
40372 { "PLAYSOUNDR", 1, 0, 0, 0},
40373 { "PLAYSOUNDV", 1, 1, 0, 0},
40374 { "LOADLWEAPONR", 1, 0, 0, 0},
40375 { "LOADLWEAPONV", 1, 1, 0, 0},
40376 { "LOADITEMR", 1, 0, 0, 0},
40377 { "LOADITEMV", 1, 1, 0, 0},
40378 { "LOADNPCR", 1, 0, 0, 0},
40379 { "LOADNPCV", 1, 1, 0, 0},
40380 { "CREATELWEAPONR", 1, 0, 0, 0},
40381 { "CREATELWEAPONV", 1, 1, 0, 0},
40382 { "CREATEITEMR", 1, 0, 0, 0},
40383 { "CREATEITEMV", 1, 1, 0, 0},
40384 { "CREATENPCR", 1, 0, 0, 0},
40385 { "CREATENPCV", 1, 1, 0, 0},
40386 { "LOADI", 2, 0, 0, 0},
40387 { "STOREI", 2, 0, 0, 0},
40388 { "GOTOR", 1, 0, 0, 0},
40389 { "SQROOTV", 2, 0, 1, 0},
40390 { "SQROOTR", 2, 0, 0, 0},
40391 { "CREATEEWEAPONR", 1, 0, 0, 0},
40392 { "CREATEEWEAPONV", 1, 1, 0, 0},
40393 { "PITWARP", 2, 1, 1, 0},
40394 { "WARPR", 2, 0, 0, 0},
40395 { "PITWARPR", 2, 0, 0, 0},
40396 { "CLEARSPRITESR", 1, 0, 0, 0},
40397 { "CLEARSPRITESV", 1, 1, 0, 0},
40398 { "RECT", 0, 0, 0, 0},
40399 { "CIRCLE", 0, 0, 0, 0},
40400 { "ARC", 0, 0, 0, 0},
40401 { "ELLIPSE", 0, 0, 0, 0},
40402 { "LINE", 0, 0, 0, 0},
40403 { "PUTPIXEL", 0, 0, 0, 0},
40404 { "DRAWTILE", 0, 0, 0, 0},
40405 { "DRAWCOMBO", 0, 0, 0, 0},
40406 { "ELLIPSE2", 0, 0, 0, 0},
40407 { "SPLINE", 0, 0, 0, 0},
40408 { "FLOODFILL", 0, 0, 0, 0},
40409 { "COMPOUNDR", 1, 0, 0, 0},
40410 { "COMPOUNDV", 1, 1, 0, 0},
40411 { "MSGSTRR", 1, 0, 0, 0},
40412 { "MSGSTRV", 1, 1, 0, 0},
40413 { "ISVALIDITEM", 1, 0, 0, 0},
40414 { "ISVALIDNPC", 1, 0, 0, 0},
40415 { "PLAYMIDIR", 1, 0, 0, 0},
40416 { "PLAYMIDIV", 1, 1, 0, 0},
40417 { "COPYTILEVV", 2, 1, 1, 0},
40418 { "COPYTILEVR", 2, 1, 0, 0},
40419 { "COPYTILERV", 2, 0, 1, 0},
40420 { "COPYTILERR", 2, 0, 0, 0},
40421 { "SWAPTILEVV", 2, 1, 1, 0},
40422 { "SWAPTILEVR", 2, 1, 0, 0},
40423 { "SWAPTILERV", 2, 0, 1, 0},
40424 { "SWAPTILERR", 2, 0, 0, 0},
40425 { "CLEARTILEV", 1, 1, 0, 0},
40426 { "CLEARTILER", 1, 0, 0, 0},
40427 { "OVERLAYTILEVV", 2, 1, 1, 0},
40428 { "OVERLAYTILEVR", 2, 1, 0, 0},
40429 { "OVERLAYTILERV", 2, 0, 1, 0},
40430 { "OVERLAYTILERR", 2, 0, 0, 0},
40431 { "FLIPROTTILEVV", 2, 1, 1, 0},
40432 { "FLIPROTTILEVR", 2, 1, 0, 0},
40433 { "FLIPROTTILERV", 2, 0, 1, 0},
40434 { "FLIPROTTILERR", 2, 0, 0, 0},
40435 { "GETTILEPIXELV", 1, 1, 0, 0},
40436 { "GETTILEPIXELR", 1, 0, 0, 0},
40437 { "SETTILEPIXELV", 1, 1, 0, 0},
40438 { "SETTILEPIXELR", 1, 0, 0, 0},
40439 { "SHIFTTILEVV", 2, 1, 1, 0},
40440 { "SHIFTTILEVR", 2, 1, 0, 0},
40441 { "SHIFTTILERV", 2, 0, 1, 0},
40442 { "SHIFTTILERR", 2, 0, 0, 0},
40443 { "ISVALIDLWPN", 1, 0, 0, 0},
40444 { "ISVALIDEWPN", 1, 0, 0, 0},
40445 { "LOADEWEAPONR", 1, 0, 0, 0},
40446 { "LOADEWEAPONV", 1, 1, 0, 0},
40447 { "ALLOCATEMEMR", 2, 0, 0, 0},
40448 { "ALLOCATEMEMV", 2, 0, 1, 0},
40449 { "ALLOCATEGMEMV", 2, 0, 1, 0},
40450 { "DEALLOCATEMEMR", 1, 0, 0, 0},
40451 { "DEALLOCATEMEMV", 1, 1, 0, 0},
40452 { "WAITDRAW", 0, 0, 0, 0},
40453 { "ARCTANR", 1, 0, 0, 0},
40454 { "LWPNUSESPRITER", 1, 0, 0, 0},
40455 { "LWPNUSESPRITEV", 1, 1, 0, 0},
40456 { "EWPNUSESPRITER", 1, 0, 0, 0},
40457 { "EWPNUSESPRITEV", 1, 1, 0, 0},
40458 { "LOADITEMDATAR", 1, 0, 0, 0},
40459 { "LOADITEMDATAV", 1, 1, 0, 0},
40460 { "BITNOT", 1, 0, 0, 0},
40461 { "LOG10", 1, 0, 0, 0},
40462 { "LOGE", 1, 0, 0, 0},
40463 { "ISSOLID", 1, 0, 0, 0},
40464 { "LAYERSCREEN", 2, 0, 0, 0},
40465 { "LAYERMAP", 2, 0, 0, 0},
40466 { "TRACE2R", 1, 0, 0, 0},
40467 { "TRACE2V", 1, 1, 0, 0},
40468 { "TRACE4", 0, 0, 0, 0},
40469 { "TRACE5", 0, 0, 0, 0},
40470 { "SECRETS", 0, 0, 0, 0},
40471 { "DRAWCHAR", 0, 0, 0, 0},
40472 { "GETSCREENFLAGS", 1, 0, 0, 0},
40473 { "QUAD", 0, 0, 0, 0},
40474 { "TRIANGLE", 0, 0, 0, 0},
40475 { "ARCSINR", 2, 0, 0, 0},
40476 { "ARCSINV", 2, 1, 0, 0},
40477 { "ARCCOSR", 2, 0, 0, 0},
40478 { "ARCCOSV", 2, 1, 0, 0},
40479 { "GAMEEND", 0, 0, 0, 0},
40480 { "DRAWINT", 0, 0, 0, 0},
40481 { "SETTRUE", 1, 0, 0, 0},
40482 { "SETFALSE", 1, 0, 0, 0},
40483 { "SETMORE", 1, 0, 0, 0},
40484 { "SETLESS", 1, 0, 0, 0},
40485 { "FASTTILE", 0, 0, 0, 0},
40486 { "FASTCOMBO", 0, 0, 0, 0},
40487 { "DRAWSTRING", 0, 0, 0, 0},
40488 { "SETSIDEWARP", 0, 0, 0, 0},
40489 { "SAVE", 0, 0, 0, 0},
40490 { "TRACE6", 0, 0, 0, 0},
40491 { "DEPRECATED", 1, 0, 0, 0},
40492 { "QUAD3D", 0, 0, 0, 0},
40493 { "TRIANGLE3D", 0, 0, 0, 0},
40494 { "SETCOLORB", 0, 0, 0, 0},
40495 { "SETDEPTHB", 0, 0, 0, 0},
40496 { "GETCOLORB", 0, 0, 0, 0},
40497 { "GETDEPTHB", 0, 0, 0, 0},
40498 { "COMBOTILE", 2, 0, 0, 0},
40499 { "SETTILEWARP", 0, 0, 0, 0},
40500 { "GETSCREENEFLAGS", 1, 0, 0, 0},
40501 { "GETSAVENAME", 1, 0, 0, 0},
40502 { "ARRAYSIZE", 1, 0, 0, 0},
40503 { "ITEMNAME", 1, 0, 0, 0},
40504 { "SETSAVENAME", 1, 0, 0, 0},
40505 { "NPCNAME", 1, 0, 0, 0},
40506 { "GETMESSAGE", 2, 0, 0, 0},
40507 { "GETDMAPNAME", 2, 0, 0, 0},
40508 { "GETDMAPTITLE", 2, 0, 0, 0},
40509 { "GETDMAPINTRO", 2, 0, 0, 0},
40510 { "ALLOCATEGMEMR", 2, 0, 0, 0},
40511 { "DRAWBITMAP", 0, 0, 0, 0},
40512 { "SETRENDERTARGET", 0, 0, 0, 0},
40513 { "PLAYENHMUSIC", 2, 0, 0, 0},
40514 { "GETMUSICFILE", 2, 0, 0, 0},
40515 { "GETMUSICTRACK", 1, 0, 0, 0},
40516 { "SETDMAPENHMUSIC", 0, 0, 0, 0},
40517 { "DRAWLAYER", 0, 0, 0, 0},
40518 { "DRAWSCREEN", 0, 0, 0, 0},
40519 { "BREAKSHIELD", 1, 0, 0, 0},
40520 { "SAVESCREEN", 1, 0, 0, 0},
40521 { "SAVEQUITSCREEN", 0, 0, 0, 0},
40522 { "SELECTAWPNR", 1, 0, 0, 0},
40523 { "SELECTAWPNV", 1, 1, 0, 0},
40524 { "SELECTBWPNR", 1, 0, 0, 0},
40525 { "SELECTBWPNV", 1, 1, 0, 0},
40526 { "GETSIDEWARPDMAP", 1, 0, 0, 0},
40527 { "GETSIDEWARPSCR", 1, 0, 0, 0},
40528 { "GETSIDEWARPTYPE", 1, 0, 0, 0},
40529 { "GETTILEWARPDMAP", 1, 0, 0, 0},
40530 { "GETTILEWARPSCR", 1, 0, 0, 0},
40531 { "GETTILEWARPTYPE", 1, 0, 0, 0},
40532 { "GETFFCSCRIPT", 1, 0, 0, 0},
40533 { "BITMAPEXR", 0, 0, 0, 0},
40534 { "__RESERVED_FOR_QUAD2R", 0, 0, 0, 0},
40535 { "WAVYIN", 0, 0, 0, 0},
40536 { "WAVYOUT", 0, 0, 0, 0},
40537 { "ZAPIN", 0, 0, 0, 0},
40538 { "ZAPOUT", 0, 0, 0, 0},
40539 { "OPENWIPE", 0, 0, 0, 0},
40540 { "FREE0x00F1", 0, 0, 0, 0 },
40541 { "FREE0x00F2", 0, 0, 0, 0},
40542 { "FREE0x00F3", 0, 0, 0,0},
40543 { "SETMESSAGE", 2, 0, 0, 0},
40544 { "SETDMAPNAME", 2, 0, 0, 0},
40545 { "SETDMAPTITLE", 2, 0, 0, 0},
40546 { "SETDMAPINTRO", 2, 0, 0, 0},
40547 { "GREYSCALEON", 0, 0, 0, 0},
40548 { "GREYSCALEOFF", 0, 0, 0, 0},
40549 { "ENDSOUNDR", 1, 0, 0, 0},
40550 { "ENDSOUNDV", 1, 1, 0, 0},
40551 { "PAUSESOUNDR", 1, 0, 0, 0},
40552 { "PAUSESOUNDV", 1, 1, 0, 0},
40553 { "RESUMESOUNDR", 1, 0, 0, 0},
40554 { "RESUMESOUNDV", 1, 1, 0, 0},
40555 { "PAUSEMUSIC", 0, 0, 0, 0},
40556 { "RESUMEMUSIC", 0, 0, 0, 0},
40557 { "LWPNARRPTR", 1, 0, 0, 0},
40558 { "EWPNARRPTR", 1, 0, 0, 0},
40559 { "EWPNARRPTR", 1, 0, 0, 0},
40560 { "IDATAARRPTR", 1, 0, 0, 0},
40561 { "FFCARRPTR", 1, 0, 0, 0},
40562 { "BOOLARRPTR", 1, 0, 0, 0},
40563 { "BOOLARRPTR", 1, 0, 0, 0},
40564 { "LWPNARRPTR2", 1, 0, 0, 0},
40565 { "EWPNARRPTR2", 1, 0, 0, 0},
40566 { "ITEMARRPTR2", 1, 0, 0, 0},
40567 { "IDATAARRPTR2", 1, 0, 0, 0},
40568 { "FFCARRPTR2", 1, 0, 0, 0},
40569 { "BOOLARRPTR2", 1, 0, 0, 0},
40570 { "NPCARRPTR2", 1, 0, 0, 0},
40571 { "ARRAYSIZEB", 1, 0, 0, 0},
40572 { "ARRAYSIZEF", 1, 0, 0, 0},
40573 { "ARRAYSIZEN", 1, 0, 0, 0},
40574 { "ARRAYSIZEL", 1, 0, 0, 0},
40575 { "ARRAYSIZEE", 1, 0, 0, 0},
40576 { "ARRAYSIZEI", 1, 0, 0, 0},
40577 { "ARRAYSIZEID", 1, 0, 0, 0},
40578 { "POLYGONR", 0, 0, 0, 0},
40579 { "__RESERVED_FOR_POLYGON3DR", 0, 0, 0, 0},
40580 { "__RESERVED_FOR_SETRENDERSOURCE", 0, 0, 0, 0},
40581 { "LINESARRAY", 0, 0, 0, 0},
40582 { "PIXELARRAYR", 0, 0, 0, 0},
40583 { "TILEARRAYR", 0, 0, 0, 0},
40584 { "COMBOARRAYR", 0, 0, 0, 0},
40585 { "RES0000", 0, 0, 0, 0},
40586 { "RES0001", 0, 0, 0, 0},
40587 { "RES0002", 0, 0, 0, 0},
40588 { "RES0003", 0, 0, 0, 0},
40589 { "RES0004", 0, 0, 0, 0},
40590 { "RES0005", 0, 0, 0, 0},
40591 { "RES0006", 0, 0, 0, 0},
40592 { "RES0007", 0, 0, 0, 0},
40593 { "RES0008", 0, 0, 0, 0},
40594 { "RES0009", 0, 0, 0, 0},
40595 { "RES000A", 0, 0, 0, 0},
40596 { "RES000B", 0, 0, 0, 0},
40597 { "RES000C", 0, 0, 0, 0},
40598 { "RES000D", 0, 0, 0, 0},
40599 { "RES000E", 0, 0, 0, 0},
40600 { "RES000F", 0, 0, 0, 0},
40601 { "__RESERVED_FOR_CREATELWPN2VV", 2, 1, 1, 0},
40602 { "__RESERVED_FOR_CREATELWPN2VR", 2, 1, 0, 0},
40603 { "__RESERVED_FOR_CREATELWPN2RV", 2, 0, 1, 0},
40604 { "__RESERVED_FOR_CREATELWPN2RR", 2, 0, 0, 0},
40605 { "GETSCREENDOOR", 1, 0, 0, 0},
40606 { "GETSCREENENEMY", 1, 0, 0, 0},
40607 { "PAUSESFX", 1, 0, 0, 0},
40608 { "RESUMESFX", 1, 0, 0, 0},
40609 { "CONTINUESFX", 1, 0, 0, 0},
40610 { "ADJUSTSFX", 0, 0, 0, 0},
40611 { "GETITEMSCRIPT", 1, 0, 0, 0},
40612 { "GETSCREENLAYOP", 1, 0, 0, 0},
40613 { "GETSCREENSECCMB", 1, 0, 0, 0},
40614 { "GETSCREENSECCST", 1, 0, 0, 0},
40615 { "GETSCREENSECFLG", 1, 0, 0, 0},
40616 { "GETSCREENLAYMAP", 1, 0, 0, 0},
40617 { "GETSCREENLAYSCR", 1, 0, 0, 0},
40618 { "GETSCREENPATH", 1, 0, 0, 0},
40619 { "GETSCREENWARPRX", 1, 0, 0, 0},
40620 { "GETSCREENWARPRY", 1, 0, 0, 0},
40621 { "TRIGGERSECRETR", 1, 0, 0, 0},
40622 { "TRIGGERSECRETV", 1, 1, 0, 0},
40623 { "NIL_UNUSED_1", 1, 0, 0, 0},
40624 { "NIL_UNUSED_2", 1, 1, 0, 0},
40625 //NPCData
40626 //one input, one return
40627 { "GETNPCDATAFLAGS", 2, 0, 0, 0},
40628 { "GETNPCDATAFLAGS2", 2, 0, 0, 0},
40629 { "GETNPCDATAWIDTH", 2, 0, 0, 0},
40630 { "GETNPCDATAHEIGHT", 2, 0, 0, 0},
40631 { "GETNPCDATASTILE", 2, 0, 0, 0},
40632 { "GETNPCDATASWIDTH", 2, 0, 0, 0},
40633 { "GETNPCDATASHEIGHT", 2, 0, 0, 0},
40634 { "GETNPCDATAETILE", 2, 0, 0, 0},
40635 { "GETNPCDATAEWIDTH", 2, 0, 0, 0},
40636 { "GETNPCDATAHP", 2, 0, 0, 0},
40637 { "GETNPCDATAFAMILY", 2, 0, 0, 0},
40638 { "GETNPCDATACSET", 2, 0, 0, 0},
40639 { "GETNPCDATAANIM", 2, 0, 0, 0},
40640 { "GETNPCDATAEANIM", 2, 0, 0, 0},
40641 { "GETNPCDATAFRAMERATE", 2, 0, 0, 0},
40642 { "GETNPCDATAEFRAMERATE", 2, 0, 0, 0},
40643 { "GETNPCDATATOUCHDMG", 2, 0, 0, 0},
40644 { "GETNPCDATAWPNDAMAGE", 2, 0, 0, 0},
40645 { "GETNPCDATAWEAPON", 2, 0, 0, 0},
40646 { "GETNPCDATARANDOM", 2, 0, 0, 0},
40647 { "GETNPCDATAHALT", 2, 0, 0, 0},
40648 { "GETNPCDATASTEP", 2, 0, 0, 0},
40649 { "GETNPCDATAHOMING", 2, 0, 0, 0},
40650 { "GETNPCDATAHUNGER", 2, 0, 0, 0},
40651 { "GETNPCDATADROPSET", 2, 0, 0, 0},
40652 { "GETNPCDATABGSFX", 2, 0, 0, 0},
40653 { "GETNPCDATADEATHSFX", 2, 0, 0, 0},
40654 { "GETNPCDATAXOFS", 2, 0, 0, 0},
40655 { "GETNPCDATAYOFS", 2, 0, 0, 0},
40656 { "GETNPCDATAZOFS", 2, 0, 0, 0},
40657 { "GETNPCDATAHXOFS", 2, 0, 0, 0},
40658 { "GETNPCDATAHYOFS", 2, 0, 0, 0},
40659 { "GETNPCDATAHITWIDTH", 2, 0, 0, 0},
40660 { "GETNPCDATAHITHEIGHT", 2, 0, 0, 0},
40661 { "GETNPCDATAHITZ", 2, 0, 0, 0},
40662 { "GETNPCDATATILEWIDTH", 2, 0, 0, 0},
40663 { "GETNPCDATATILEHEIGHT", 2, 0, 0, 0},
40664 { "GETNPCDATAWPNSPRITE", 2, 0, 0, 0},
40665 //two inputs one return
40666 { "GETNPCDATASCRIPTDEF", 1, 0, 0, 0},
40667 { "GETNPCDATADEFENSE", 1, 0, 0, 0},
40668 { "GETNPCDATASIZEFLAG", 1, 0, 0, 0},
40669 { "GETNPCDATAATTRIBUTE", 1, 0, 0, 0},
40670 //two inputs no return
40671 { "SETNPCDATAFLAGS", 2, 0, 0, 0},
40672 { "SETNPCDATAFLAGS2", 2, 0, 0, 0},
40673 { "SETNPCDATAWIDTH", 2, 0, 0, 0},
40674 { "SETNPCDATAHEIGHT", 2, 0, 0, 0},
40675 { "SETNPCDATASTILE", 2, 0, 0, 0},
40676 { "SETNPCDATASWIDTH", 2, 0, 0, 0},
40677 { "SETNPCDATASHEIGHT", 2, 0, 0, 0},
40678 { "SETNPCDATAETILE", 2, 0, 0, 0},
40679 { "SETNPCDATAEWIDTH", 2, 0, 0, 0},
40680 { "SETNPCDATAHP", 2, 0, 0, 0},
40681 { "SETNPCDATAFAMILY", 2, 0, 0, 0},
40682 { "SETNPCDATACSET", 2, 0, 0, 0},
40683 { "SETNPCDATAANIM", 2, 0, 0, 0},
40684 { "SETNPCDATAEANIM", 2, 0, 0, 0},
40685 { "SETNPCDATAFRAMERATE", 2, 0, 0, 0},
40686 { "SETNPCDATAEFRAMERATE", 2, 0, 0, 0},
40687 { "SETNPCDATATOUCHDMG", 2, 0, 0, 0},
40688 { "SETNPCDATAWPNDAMAGE", 2, 0, 0, 0},
40689 { "SETNPCDATAWEAPON", 2, 0, 0, 0},
40690 { "SETNPCDATARANDOM", 2, 0, 0, 0},
40691 { "SETNPCDATAHALT", 2, 0, 0, 0},
40692 { "SETNPCDATASTEP", 2, 0, 0, 0},
40693 { "SETNPCDATAHOMING", 2, 0, 0, 0},
40694 { "SETNPCDATAHUNGER", 2, 0, 0, 0},
40695 { "SETNPCDATADROPSET", 2, 0, 0, 0},
40696 { "SETNPCDATABGSFX", 2, 0, 0, 0},
40697 { "SETNPCDATADEATHSFX", 2, 0, 0, 0},
40698 { "SETNPCDATAXOFS", 2, 0, 0, 0},
40699 { "SETNPCDATAYOFS", 2, 0, 0, 0},
40700 { "SETNPCDATAZOFS", 2, 0, 0, 0},
40701 { "SETNPCDATAHXOFS", 2, 0, 0, 0},
40702 { "SETNPCDATAHYOFS", 2, 0, 0, 0},
40703 { "SETNPCDATAHITWIDTH", 2, 0, 0, 0},
40704 { "SETNPCDATAHITHEIGHT", 2, 0, 0, 0},
40705 { "SETNPCDATAHITZ", 2, 0, 0, 0},
40706 { "SETNPCDATATILEWIDTH", 2, 0, 0, 0},
40707 { "SETNPCDATATILEHEIGHT", 2, 0, 0, 0},
40708 { "SETNPCDATAWPNSPRITE", 2, 0, 0, 0},
40709 { "SETNPCDATAHITSFX", 2, 0, 0, 0},
40710 { "GETNPCDATAHITSFX", 2, 0, 0, 0},
40711 //Combodata, one input no return
40712 { "GCDBLOCKENEM", 2, 0, 0, 0},
40713 { "GCDBLOCKHOLE", 2, 0, 0, 0},
40714 { "GCDBLOCKTRIG", 2, 0, 0, 0},
40715 { "GCDCONVEYSPDX", 2, 0, 0, 0},
40716 { "GCDCONVEYSPDY", 2, 0, 0, 0},
40717 { "GCDCREATEENEM", 2, 0, 0, 0},
40718 { "GCDCREATEENEMWH", 2, 0, 0, 0},
40719 { "GCDCREATEENEMCH", 2, 0, 0, 0},
40720 { "GCDDIRCHTYPE", 2, 0, 0, 0},
40721 { "GCDDISTCHTILES", 2, 0, 0, 0},
40722 { "GCDDIVEITEM", 2, 0, 0, 0},
40723 { "GCDDOCK", 2, 0, 0, 0},
40724 { "GCDFAIRY", 2, 0, 0, 0},
40725 { "GCDFFCOMBOATTRIB", 2, 0, 0, 0},
40726 { "GCDFOOTDECOTILE", 2, 0, 0, 0},
40727 { "GCDFOOTDECOTYPE", 2, 0, 0, 0},
40728 { "GCDHOOKSHOTGRAB", 2, 0, 0, 0},
40729 { "GCDLADDERPASS", 2, 0, 0, 0},
40730 { "GCDLOCKBLOCKTYPE", 2, 0, 0, 0},
40731 { "GCDLOCKBLOCKCHANGE", 2, 0, 0, 0},
40732 { "GCDMAGICMIRRORTYPE", 2, 0, 0, 0},
40733 { "GCDMODIFYHPAMOUNT", 2, 0, 0, 0},
40734 { "GCDMODIFYHPDELAY", 2, 0, 0, 0},
40735 { "GCDMODIFYHPTYPE", 2, 0, 0, 0},
40736 { "GCDMODIFYMPAMOUNT", 2, 0, 0, 0},
40737 { "GCDMODIFYMPDELAY", 2, 0, 0, 0},
40738 { "GCDMODIFYMPTYPE", 2, 0, 0, 0},
40739 { "GCDNOPUSHBLOCKS", 2, 0, 0, 0},
40740 { "GCDOVERHEAD", 2, 0, 0, 0},
40741 { "GCDPLACEENEMY", 2, 0, 0, 0},
40742 { "GCDPUSHDIR", 2, 0, 0, 0},
40743 { "GCDPUSHWEIGHT", 2, 0, 0, 0},
40744 { "GCDPUSHWAIT", 2, 0, 0, 0},
40745 { "GCDPUSHED", 2, 0, 0, 0},
40746 { "GCDRAFT", 2, 0, 0, 0},
40747 { "GCDRESETROOM", 2, 0, 0, 0},
40748 { "GCDSAVEPOINT", 2, 0, 0, 0},
40749 { "GCDSCREENFREEZE", 2, 0, 0, 0},
40750 { "GCDSECRETCOMBO", 2, 0, 0, 0},
40751 { "GCDSINGULAR", 2, 0, 0, 0},
40752 { "GCDSLOWMOVE", 2, 0, 0, 0},
40753 { "GCDSTATUE", 2, 0, 0, 0},
40754 { "GCDSTEPTYPE", 2, 0, 0, 0},
40755 { "GCDSTEPCHANGETO", 2, 0, 0, 0},
40756 { "GCDSTRIKEREMNANTS", 2, 0, 0, 0},
40757 { "GCDSTRIKEREMNANTSTYPE", 2, 0, 0, 0},
40758 { "GCDSTRIKECHANGE", 2, 0, 0, 0},
40759 { "GCDSTRIKECHANGEITEM", 2, 0, 0, 0},
40760 { "GCDTOUCHITEM", 2, 0, 0, 0},
40761 { "GCDTOUCHSTAIRS", 2, 0, 0, 0},
40762 { "GCDTRIGGERTYPE", 2, 0, 0, 0},
40763 { "GCDTRIGGERSENS", 2, 0, 0, 0},
40764 { "GCDWARPTYPE", 2, 0, 0, 0},
40765 { "GCDWARPSENS", 2, 0, 0, 0},
40766 { "GCDWARPDIRECT", 2, 0, 0, 0},
40767 { "GCDWARPLOCATION", 2, 0, 0, 0},
40768 { "GCDWATER", 2, 0, 0, 0},
40769 { "GCDWHISTLE", 2, 0, 0, 0},
40770 { "GCDWINGAME", 2, 0, 0, 0},
40771 { "GCDBLOCKWEAPLVL", 2, 0, 0, 0},
40772 { "GCDTILE", 2, 0, 0, 0},
40773 { "GCDFLIP", 2, 0, 0, 0},
40774 { "GCDWALK", 2, 0, 0, 0},
40775 { "GCDTYPE", 2, 0, 0, 0},
40776 { "GCDCSETS", 2, 0, 0, 0},
40777 { "GCDFOO", 2, 0, 0, 0},
40778 { "GCDFRAMES", 2, 0, 0, 0},
40779 { "GCDSPEED", 2, 0, 0, 0},
40780 { "GCDNEXTCOMBO", 2, 0, 0, 0},
40781 { "GCDNEXTCSET", 2, 0, 0, 0},
40782 { "GCDFLAG", 2, 0, 0, 0},
40783 { "GCDSKIPANIM", 2, 0, 0, 0},
40784 { "GCDNEXTTIMER", 2, 0, 0, 0},
40785 { "GCDSKIPANIMY", 2, 0, 0, 0},
40786 { "GCDANIMFLAGS", 2, 0, 0, 0},
40787 //combodata two input, one return
40788 { "GCDBLOCKWEAPON", 1, 0, 0, 0},
40789 { "GCDEXPANSION", 1, 0, 0, 0},
40790 { "GCDSTRIKEWEAPONS", 1, 0, 0, 0},
40791 //combodata two input, one return
40792 { "SCDBLOCKENEM", 2, 0, 0, 0},
40793 { "SCDBLOCKHOLE", 2, 0, 0, 0},
40794 { "SCDBLOCKTRIG", 2, 0, 0, 0},
40795 { "SCDCONVEYSPDX", 2, 0, 0, 0},
40796 { "SCDCONVEYSPDY", 2, 0, 0, 0},
40797 { "SCDCREATEENEM", 2, 0, 0, 0},
40798 { "SCDCREATEENEMWH", 2, 0, 0, 0},
40799 { "SCDCREATEENEMCH", 2, 0, 0, 0},
40800 { "SCDDIRCHTYPE", 2, 0, 0, 0},
40801 { "SCDDISTCHTILES", 2, 0, 0, 0},
40802 { "SCDDIVEITEM", 2, 0, 0, 0},
40803 { "SCDDOCK", 2, 0, 0, 0},
40804 { "SCDFAIRY", 2, 0, 0, 0},
40805 { "SCDFFCOMBOATTRIB", 2, 0, 0, 0},
40806 { "SCDFOOTDECOTILE", 2, 0, 0, 0},
40807 { "SCDFOOTDECOTYPE", 2, 0, 0, 0},
40808 { "SCDHOOKSHOTGRAB", 2, 0, 0, 0},
40809 { "SCDLADDERPASS", 2, 0, 0, 0},
40810 { "SCDLOCKBLOCKTYPE", 2, 0, 0, 0},
40811 { "SCDLOCKBLOCKCHANGE", 2, 0, 0, 0},
40812 { "SCDMAGICMIRRORTYPE", 2, 0, 0, 0},
40813 { "SCDMODIFYHPAMOUNT", 2, 0, 0, 0},
40814 { "SCDMODIFYHPDELAY", 2, 0, 0, 0},
40815 { "SCDMODIFYHPTYPE", 2, 0, 0, 0},
40816 { "SCDMODIFYMPAMOUNT", 2, 0, 0, 0},
40817 { "SCDMODIFYMPDELAY", 2, 0, 0, 0},
40818 { "SCDMODIFYMPTYPE", 2, 0, 0, 0},
40819 { "SCDNOPUSHBLOCKS", 2, 0, 0, 0},
40820 { "SCDOVERHEAD", 2, 0, 0, 0},
40821 { "SCDPLACEENEMY", 2, 0, 0, 0},
40822 { "SCDPUSHDIR", 2, 0, 0, 0},
40823 { "SCDPUSHWEIGHT", 2, 0, 0, 0},
40824 { "SCDPUSHWAIT", 2, 0, 0, 0},
40825 { "SCDPUSHED", 2, 0, 0, 0},
40826 { "SCDRAFT", 2, 0, 0, 0},
40827 { "SCDRESETROOM", 2, 0, 0, 0},
40828 { "SCDSAVEPOINT", 2, 0, 0, 0},
40829 { "SCDSCREENFREEZE", 2, 0, 0, 0},
40830 { "SCDSECRETCOMBO", 2, 0, 0, 0},
40831 { "SCDSINGULAR", 2, 0, 0, 0},
40832 { "SCDSLOWMOVE", 2, 0, 0, 0},
40833 { "SCDSTATUE", 2, 0, 0, 0},
40834 { "SCDSTEPTYPE", 2, 0, 0, 0},
40835 { "SCDSTEPCHANGETO", 2, 0, 0, 0},
40836 { "SCDSTRIKEREMNANTS", 2, 0, 0, 0},
40837 { "SCDSTRIKEREMNANTSTYPE", 2, 0, 0, 0},
40838 { "SCDSTRIKECHANGE", 2, 0, 0, 0},
40839 { "SCDSTRIKECHANGEITEM", 2, 0, 0, 0},
40840 { "SCDTOUCHITEM", 2, 0, 0, 0},
40841 { "SCDTOUCHSTAIRS", 2, 0, 0, 0},
40842 { "SCDTRIGGERTYPE", 2, 0, 0, 0},
40843 { "SCDTRIGGERSENS", 2, 0, 0, 0},
40844 { "SCDWARPTYPE", 2, 0, 0, 0},
40845 { "SCDWARPSENS", 2, 0, 0, 0},
40846 { "SCDWARPDIRECT", 2, 0, 0, 0},
40847 { "SCDWARPLOCATION", 2, 0, 0, 0},
40848 { "SCDWATER", 2, 0, 0, 0},
40849 { "SCDWHISTLE", 2, 0, 0, 0},
40850 { "SCDWINGAME", 2, 0, 0, 0},
40851 { "SCDBLOCKWEAPLVL", 2, 0, 0, 0},
40852 { "SCDTILE", 2, 0, 0, 0},
40853 { "SCDFLIP", 2, 0, 0, 0},
40854 { "SCDWALK", 2, 0, 0, 0},
40855 { "SCDTYPE", 2, 0, 0, 0},
40856 { "SCDCSETS", 2, 0, 0, 0},
40857 { "SCDFOO", 2, 0, 0, 0},
40858 { "SCDFRAMES", 2, 0, 0, 0},
40859 { "SCDSPEED", 2, 0, 0, 0},
40860 { "SCDNEXTCOMBO", 2, 0, 0, 0},
40861 { "SCDNEXTCSET", 2, 0, 0, 0},
40862 { "SCDFLAG", 2, 0, 0, 0},
40863 { "SCDSKIPANIM", 2, 0, 0, 0},
40864 { "SCDNEXTTIMER", 2, 0, 0, 0},
40865 { "SCDSKIPANIMY", 2, 0, 0, 0},
40866 { "SCDANIMFLAGS", 2, 0, 0, 0},
40867 { "GETNPCDATATILE", 2, 0, 0, 0},
40868 { "GETNPCDATAEHEIGHT", 2, 0, 0, 0},
40869 { "SETNPCDATATILE", 2, 0, 0, 0},
40870 { "SETNPCDATAEHEIGHT", 2, 0, 0, 0},
40871 { "GETSPRITEDATASTRING", 2, 0, 0, 0},
40872 //SpriteData
40873 { "GETSPRITEDATATILE", 2, 0, 0, 0},
40874 { "GETSPRITEDATAMISC", 2, 0, 0, 0},
40875 { "GETSPRITEDATACGETS", 2, 0, 0, 0},
40876 { "GETSPRITEDATAFRAMES", 2, 0, 0, 0},
40877 { "GETSPRITEDATASPEED", 2, 0, 0, 0},
40878 { "GETSPRITEDATATYPE", 2, 0, 0, 0},
40879 { "SETSPRITEDATASTRING", 2, 0, 0, 0},
40880 { "SETSPRITEDATATILE", 2, 0, 0, 0},
40881 { "SETSPRITEDATAMISC", 2, 0, 0, 0},
40882 { "SETSPRITEDATACSETS", 2, 0, 0, 0},
40883 { "SETSPRITEDATAFRAMES", 2, 0, 0, 0},
40884 { "SETSPRITEDATASPEED", 2, 0, 0, 0},
40885 { "SETSPRITEDATATYPE", 2, 0, 0, 0},
40886 //Game->SetContinueScreenSetting
40887 { "SETCONTINUESCREEN", 2, 0, 0, 0},
40888 //Game->SetContinueScreenString
40889 { "SETCONTINUESTRING", 2, 0, 0, 0},
40890
40891 { "LOADNPCDATAR", 1, 0, 0, 0},
40892 { "LOADNPCDATAV", 1, 1, 0, 0},
40893
40894 { "LOADCOMBODATAR", 1, 0, 0, 0},
40895 { "LOADCOMBODATAV", 1, 1, 0, 0},
40896
40897 { "LOADMAPDATAR", 1, 0, 0, 0},
40898 { "LOADMAPDATAV", 1, 1, 0, 0},
40899
40900 { "LOADSPRITEDATAR", 1, 0, 0, 0},
40901 { "LOADSPRITEDATAV", 1, 1, 0, 0},
40902
40903 { "LOADSCREENDATAR", 1, 0, 0, 0},
40904 { "LOADSCREENDATAV", 1, 1, 0, 0},
40905
40906 { "LOADBITMAPDATAR", 1, 0, 0, 0},
40907 { "LOADBITMAPDATAV", 1, 1, 0, 0},
40908
40909 { "LOADSHOPR", 1, 0, 0, 0},
40910 { "LOADSHOPV", 1, 1, 0, 0},
40911
40912 { "LOADINFOSHOPR", 1, 0, 0, 0},
40913 { "LOADINFOSHOPV", 1, 1, 0, 0},
40914
40915 { "LOADMESSAGEDATAR", 1, 0, 0, 0},
40916 { "LOADMESSAGEDATAV", 1, 1, 0, 0},
40917 { "MESSAGEDATASETSTRINGR", 1, 0, 0, 0},
40918 { "MESSAGEDATASETSTRINGV", 1, 1, 0, 0},
40919 { "MESSAGEDATAGETSTRINGR", 1, 0, 0, 0},
40920 { "MESSAGEDATAGETSTRINGV", 1, 1, 0, 0},
40921
40922 { "LOADDMAPDATAR", 1, 0, 0, 0},
40923 { "LOADDMAPDATAV", 1, 1, 0, 0},
40924 { "DMAPDATAGETNAMER", 1, 0, 0, 0},
40925 { "DMAPDATAGETNAMEV", 1, 1, 0, 0},
40926 { "DMAPDATASETNAMER", 1, 0, 0, 0},
40927 { "DMAPDATASETNAMEV", 1, 1, 0, 0},
40928 { "DMAPDATAGETTITLER", 1, 0, 0, 0},
40929 { "DMAPDATAGETTITLEV", 1, 1, 0, 0},
40930 { "DMAPDATASETTITLER", 1, 0, 0, 0},
40931 { "DMAPDATASETTITLEV", 1, 1, 0, 0},
40932
40933 { "DMAPDATAGETINTROR", 1, 0, 0, 0},
40934 { "DMAPDATAGETINTROV", 1, 1, 0, 0},
40935 { "DMAPDATANSETITROR", 1, 0, 0, 0},
40936 { "DMAPDATASETINTROV", 1, 1, 0, 0},
40937 { "DMAPDATAGETMUSICR", 1, 0, 0, 0},
40938 { "DMAPDATAGETMUSICV", 1, 1, 0, 0},
40939 { "DMAPDATASETMUSICR", 1, 0, 0, 0},
40940 { "DMAPDATASETMUSICV", 1, 1, 0, 0},
40941
40942 { "ADJUSTSFXVOLUMER", 1, 0, 0, 0},
40943 { "ADJUSTSFXVOLUMEV", 1, 1, 0, 0},
40944
40945 { "ADJUSTVOLUMER", 1, 0, 0, 0},
40946 { "ADJUSTVOLUMEV", 1, 1, 0, 0},
40947
40948 { "FXWAVYR", 1, 0, 0, 0},
40949 { "FXWAVYV", 1, 1, 0, 0},
40950
40951 { "FXZAPR", 1, 0, 0, 0},
40952 { "FXZAPV", 1, 1, 0, 0},
40953
40954 { "GREYSCALER", 1, 0, 0, 0},
40955 { "GREYSCALEV", 1, 1, 0, 0},
40956 { "RETURN", 0, 0, 0, 0},
40957 { "MONOCHROMER", 1, 0, 0, 0},
40958 { "MONOCHROMEV", 1, 1, 0, 0},
40959 { "CLEARTINT", 0, 0, 0, 0},
40960 { "TINT", 0, 0, 0, 0},
40961 { "MONOHUE", 0, 0, 0, 0},
40962
40963 { "BMPRECTR", 0, 0, 0, 0},
40964 { "BMPCIRCLER", 0, 0, 0, 0},
40965 { "BMPARCR", 0, 0, 0, 0},
40966 { "BMPELLIPSER", 0, 0, 0, 0},
40967 { "BMPLINER", 0, 0, 0, 0},
40968 { "BMPSPLINER", 0, 0, 0, 0},
40969 { "BMPPUTPIXELR", 0, 0, 0, 0},
40970 { "BMPDRAWTILER", 0, 0, 0, 0},
40971 { "BMPDRAWCOMBOR", 0, 0, 0, 0},
40972 { "BMPFASTTILER", 0, 0, 0, 0},
40973 { "BMPFASTCOMBOR", 0, 0, 0, 0},
40974 { "BMPDRAWCHARR", 0, 0, 0, 0},
40975 { "BMPDRAWINTR", 0, 0, 0, 0},
40976 { "BMPDRAWSTRINGR", 0, 0, 0, 0},
40977 { "BMPQUADR", 0, 0, 0, 0},
40978 { "BMPQUAD3DR", 0, 0, 0, 0},
40979 { "BMPTRIANGLER", 0, 0, 0, 0},
40980 { "BMPTRIANGLE3DR", 0, 0, 0, 0},
40981 { "BMPPOLYGONR", 0, 0, 0, 0},
40982 { "BMPDRAWLAYERR", 0, 0, 0, 0},
40983 { "BMPDRAWSCREENR", 0, 0, 0, 0},
40984 { "BMPBLIT", 0, 0, 0, 0},
40985
40986 { "LINKWARPEXR", 1, 0, 0, 0},
40987 { "LINKWARPEXV", 1, 1, 0, 0},
40988 { "LINKEXPLODER", 1, 0, 0, 0},
40989 { "LINKEXPLODEV", 1, 1, 0, 0},
40990 { "NPCEXPLODER", 1, 0, 0, 0},
40991 { "NPCEXPLODEV", 1, 1, 0, 0},
40992
40993 { "ITEMEXPLODER", 1, 0, 0, 0},
40994 { "ITEMEXPLODEV", 1, 1, 0, 0},
40995 { "LWEAPONEXPLODER", 1, 0, 0, 0},
40996 { "LWEAPONEXPLODEV", 1, 1, 0, 0},
40997 { "EWEAPONEXPLODER", 1, 0, 0, 0},
40998 { "EWEAPONEXPLODEV", 1, 1, 0, 0},
40999 { "RUNITEMSCRIPT", 0, 0, 0, 0},
41000 { "GETRTCTIMER", 1, 0, 0, 0},
41001 { "GETRTCTIMEV", 1, 1, 0, 0},
41002
41003 //new npc functions for npc scripts
41004 { "NPCDEAD", 1, 0, 0, 0},
41005 { "NPCKICKBUCKET", 0, 0, 0, 0},
41006 { "NPCSTOPBGSFX", 0, 0, 0, 0},
41007 { "NPCCANMOVE", 1, 0, 0, 0},
41008 { "NPCNEWDIR8", 0, 0, 0, 0},
41009 { "NPCNEWDIR", 0, 0, 0, 0},
41010 { "NPCCONSTWALK", 0, 0, 0, 0},
41011 { "NPCCONSTWALK8", 0, 0, 0, 0},
41012 { "NPCVARWALK", 0, 0, 0, 0},
41013 { "NPCVARWALK8", 0, 0, 0, 0},
41014 { "NPCHALTWALK", 0, 0, 0, 0},
41015 { "NPCHALTWALK8", 0, 0, 0, 0},
41016 { "NPCFLOATWALK", 0, 0, 0, 0},
41017 // moved to a var: { "NPCLINEDUP", 0, 0, 0, 0},
41018 { "NPCLINKINRANGE", 1, 0, 0, 0},
41019 { "NPCATTACK", 0, 0, 0, 0},
41020 { "NPCPLACEONAXIS", 0, 0, 0, 0},
41021 { "NPCADD", 1, 0, 0, 0},
41022 { "NPCFIREBREATH", 0, 0, 0, 0},
41023 { "NPCCANSLIDE", 1, 0, 0, 0},
41024 { "NPCSLIDE", 1, 0, 0, 0},
41025 { "NPCHITWITH", 1, 0, 0, 0},
41026 { "NPCGETINITDLABEL", 0, 0, 0, 0},
41027 // moved to a var: { "NPCCOLLISION", 0, 0, 0, 0}, //how to implement this?
41028 { "GAMECONTINUE", 0, 0, 0, 0},
41029 { "MAPDATAISSOLID", 1, 0, 0, 0},
41030 { "SHOWF6SCREEN", 0, 0, 0, 0},
41031 { "NPCDATAGETNAME", 1, 0, 0, 0},
41032 { "PLAYENHMUSICEX", 2, 0, 0, 0},
41033 { "GETENHMUSICPOS", 1, 0, 0, 0},
41034 { "SETENHMUSICPOS", 1, 0, 0, 0},
41035 { "SETENHMUSICSPEED", 1, 0, 0, 0},
41036 { "ISVALIDBITMAP", 1, 0, 0, 0},
41037 { "READBITMAP", 0, 0, 0, 0},
41038 { "WRITEBITMAP", 0, 0, 0, 0},
41039 { "ALLOCATEBITMAP", 1, 0, 0, 0},
41040 { "CLEARBITMAP", 0, 0, 0, 0},
41041 { "REGENERATEBITMAP", 0, 0, 0, 0},
41042 { "BMPBLITTO", 0, 0, 0, 0},
41043
41044 { "BMPDRAWSCREENSOLIDR", 0, 0, 0, 0},
41045 { "BMPDRAWSCREENCOMBOFR", 0, 0, 0, 0},
41046 { "BMPDRAWSCREENCOMBOIR", 0, 0, 0, 0},
41047 { "BMPDRAWSCREENCOMBOTR", 0, 0, 0, 0},
41048 { "BMPDRAWSCREENSOLID2R", 0, 0, 0, 0},
41049 { "GRAPHICSGETPIXEL", 1, 0, 0, 0},
41050
41051 { "BMPDRAWLAYERSOLIDR", 0, 0, 0, 0},
41052 { "BMPDRAWLAYERCFLAGR", 0, 0, 0, 0},
41053 { "BMPDRAWLAYERCTYPER", 0, 0, 0, 0},
41054 { "BMPDRAWLAYERCIFLAGR", 0, 0, 0, 0},
41055 { "BMPDRAWLAYERSOLIDITYR", 0, 0, 0, 0},
41056 { "BMPMODE7", 0, 0, 0, 0},
41057 { "BITMAPGETPIXEL", 0, 0, 0, 0},
41058 { "NOP", 0, 0, 0, 0},
41059 { "STRINGCOMPARE", 1, 0, 0, 0},
41060 { "STRINGNCOMPARE", 1, 0, 0, 0},
41061 { "STRINGLENGTH", 2, 0, 0, 0},
41062 { "STRINGCOPY", 2, 0, 0, 0},
41063 { "CASTBOOLI", 1, 0, 0, 0},
41064 { "CASTBOOLF", 1, 0, 0, 0},
41065 { "SETTRUEI", 1, 0, 0, 0},
41066 { "SETFALSEI", 1, 0, 0, 0},
41067 { "SETMOREI", 1, 0, 0, 0},
41068 { "SETLESSI", 1, 0, 0, 0},
41069
41070 { "ARRAYCOPY", 2, 0, 0, 0},
41071 { "ARRAYNCOPY", 1, 0, 0, 0},
41072
41073 //1 INPUT, NO RETURN
41074 { "REMCHR", 2, 0, 0, 0},
41075 { "STRINGUPPERLOWER", 2, 0, 0, 0},
41076 { "STRINGLOWERUPPER", 2, 0, 0, 0},
41077 { "STRINGCONVERTCASE", 2, 0, 0, 0},
41078
41079 //1 input, 1 ret
41080 { "XLEN", 2, 0, 0, 0},
41081 { "XTOI", 2, 0, 0, 0},
41082 { "ILEN", 2, 0, 0, 0},
41083 { "ATOI", 2, 0, 0, 0},
41084
41085 //2 INPUT, 1 RET, based on strcmp
41086 { "STRCSPN", 1, 0, 0, 0},
41087 { "STRSTR", 1, 0, 0, 0},
41088 { "XTOA", 2, 0, 0, 0},
41089 { "ITOA", 2, 0, 0, 0},
41090 { "STRCAT", 1, 0, 0, 0},
41091 { "STRSPN", 1, 0, 0, 0},
41092 { "STRCHR", 1, 0, 0, 0},
41093 { "STRRCHR", 1, 0, 0, 0},
41094 //2 INP, 1 RET OVERLOADS
41095 { "XLEN2", 1, 0, 0, 0},
41096 { "XTOI2", 1, 0, 0, 0},
41097 { "ILEN2", 1, 0, 0, 0},
41098 { "ATOI2", 1, 0, 0, 0},
41099 { "REMCHR2", 1, 0, 0, 0},
41100
41101 //3 INPUT 1 RET
41102 { "XTOA3", 1, 0, 0, 0},
41103 { "STRCATF", 1, 0, 0, 0},
41104 { "ITOA3", 1, 0, 0, 0},
41105 { "STRSTR3", 1, 0, 0, 0},
41106 { "REMNCHR3", 1, 0, 0, 0},
41107 { "STRCAT3", 1, 0, 0, 0},
41108 { "STRNCAT3", 1, 0, 0, 0},
41109 { "STRCHR3", 1, 0, 0, 0},
41110 { "STRRCHR3", 1, 0, 0, 0},
41111 { "STRSPN3", 1, 0, 0, 0},
41112 { "STRCSPN3", 1, 0, 0, 0},
41113
41114
41115 { "UPPERTOLOWER", 2, 0, 0, 0},
41116 { "LOWERTOUPPER", 2, 0, 0, 0},
41117 { "CONVERTCASE", 2, 0, 0, 0},
41118 //Game->Get
41119 { "GETNPCSCRIPT", 1, 0, 0, 0},
41120 { "GETLWEAPONSCRIPT", 1, 0, 0, 0},
41121 { "GETEWEAPONSCRIPT", 1, 0, 0, 0},
41122 { "GETHEROSCRIPT", 1, 0, 0, 0},
41123 { "GETGLOBALSCRIPT", 1, 0, 0, 0},
41124 { "GETDMAPSCRIPT", 1, 0, 0, 0},
41125 { "GETSCREENSCRIPT", 1, 0, 0, 0},
41126 { "GETSPRITESCRIPT", 1, 0, 0, 0},
41127 { "GETUNTYPEDSCRIPT", 1, 0, 0, 0},
41128 { "GETSUBSCREENSCRIPT", 1, 0, 0, 0},
41129 { "GETNPCBYNAME", 1, 0, 0, 0},
41130 { "GETITEMBYNAME", 1, 0, 0, 0},
41131 { "GETCOMBOBYNAME", 1, 0, 0, 0},
41132 { "GETDMAPBYNAME", 1, 0, 0, 0},
41133
41134 { "SRNDR", 1, 0, 0, 0},
41135 { "SRNDV", 1, 1, 0, 0},
41136 { "SRNDRND", 1, 0, 0, 0},
41137 { "SAVEGAMESTRUCTS", 2, 0, 0, 0},
41138 { "READGAMESTRUCTS", 2, 0, 0, 0},
41139 { "ANDR32", 2, 0, 0, 0},
41140 { "ANDV32", 2, 0, 1, 0},
41141 { "ORR32", 2, 0, 0, 0},
41142 { "ORV32", 2, 0, 1, 0},
41143 { "XORR32", 2, 0, 0, 0},
41144 { "XORV32", 2, 0, 1, 0},
41145 { "BITNOT32", 1, 0, 0, 0},
41146 { "LSHIFTR32", 2, 0, 0, 0},
41147 { "LSHIFTV32", 2, 0, 1, 0},
41148 { "RSHIFTR32", 2, 0, 0, 0},
41149 { "RSHIFTV32", 2, 0, 1, 0},
41150 { "ISALLOCATEDBITMAP", 1, 0, 0, 0},
41151 { "FONTHEIGHTR", 1, 0, 0, 0},
41152 { "STRINGWIDTHR", 2, 0, 0, 0},
41153 { "CHARWIDTHR", 2, 0, 0, 0},
41154 { "MESSAGEWIDTHR", 1, 0, 0, 0},
41155 { "MESSAGEHEIGHTR", 1, 0, 0, 0},
41156 { "ISVALIDARRAY", 1, 0, 0, 0},
41157 { "DIREXISTS", 1, 0, 0, 0},
41158 { "GAMESAVEQUIT", 0, 0, 0, 0},
41159 { "GAMESAVECONTINUE", 0, 0, 0, 0},
41160 { "DRAWTILECLOAKEDR", 0, 0, 0, 0},
41161 { "BMPDRAWTILECLOAKEDR", 0, 0, 0, 0},
41162 { "DRAWCOMBOCLOAKEDR", 0, 0, 0, 0},
41163 { "BMPDRAWCOMBOCLOAKEDR", 0, 0, 0, 0},
41164 { "NPCKNOCKBACK", 2, 0, 0, 0},
41165 { "CLOSEWIPE", 0, 0, 0, 0},
41166 { "OPENWIPESHAPE", 1, 0, 0, 0},
41167 { "CLOSEWIPESHAPE", 1, 0, 0, 0},
41168 { "FILEEXISTS", 1, 0, 0, 0},
41169 { "BITMAPCLEARTOCOLOR", 0, 0, 0, 0},
41170 { "LOADNPCBYSUID", 1, 0, 0, 0},
41171 { "LOADLWEAPONBYSUID", 1, 0, 0, 0},
41172 { "LOADWEAPONCBYSUID", 1, 0, 0, 0},
41173 { "LOADDROPSETR", 1, 0, 0, 0},
41174 { "LOADTMPSCR", 1, 0, 0, 0},
41175 { "LOADSCROLLSCR", 1, 0, 0, 0},
41176 { "MAPDATAISSOLIDLYR", 1, 0, 0, 0},
41177 { "ISSOLIDLAYER", 1, 0, 0, 0},
41178 { "BREAKPOINT", 1, 0, 0, 0},
41179 { "TOBYTE", 1, 0, 0, 0},
41180 { "TOWORD", 1, 0, 0, 0},
41181 { "TOSHORT", 1, 0, 0, 0},
41182 { "TOSIGNEDBYTE", 1, 0, 0, 0},
41183 { "TOINTEGER", 1, 0, 0, 0},
41184 { "FLOOR", 1, 0, 0, 0},
41185 { "CEILING", 1, 0, 0, 0},
41186
41187 { "FILECLOSE", 0, 0, 0, 0},
41188 { "FILEFREE", 0, 0, 0, 0},
41189 { "FILEISALLOCATED", 0, 0, 0, 0},
41190 { "FILEISVALID", 0, 0, 0, 0},
41191 { "FILEALLOCATE", 0, 0, 0, 0},
41192 { "FILEFLUSH", 0, 0, 0, 0},
41193 { "FILEGETCHAR", 0, 0, 0, 0},
41194 { "FILEREWIND", 0, 0, 0, 0},
41195 { "FILECLEARERR", 0, 0, 0, 0},
41196
41197 { "FILEOPEN", 1, 0, 0, 0},
41198 { "FILECREATE", 1, 0, 0, 0},
41199 { "FILEREADSTR", 1, 0, 0, 0},
41200 { "FILEWRITESTR", 1, 0, 0, 0},
41201 { "FILEPUTCHAR", 1, 0, 0, 0},
41202 { "FILEUNGETCHAR", 1, 0, 0, 0},
41203
41204 { "FILEREADCHARS", 2, 0, 0, 0},
41205 { "FILEREADINTS", 2, 0, 0, 0},
41206 { "FILEWRITECHARS", 2, 0, 0, 0},
41207 { "FILEWRITEINTS", 2, 0, 0, 0},
41208 { "FILESEEK", 2, 0, 0, 0},
41209 { "FILEOPENMODE", 2, 0, 0, 0},
41210 { "FILEGETERROR", 1, 0, 0, 0},
41211
41212 { "BITMAPFREE", 0, 0, 0, 0},
41213
41214 { "POPARGS", 2, 0, 1, 0},
41215 { "GAMERELOAD", 0, 0, 0, 0},
41216
41217 { "READPODARRAYR", 2, 0, 0, 0},
41218 { "READPODARRAYV", 2, 0, 1, 0},
41219 { "WRITEPODARRAYRR", 2, 0, 0, 0},
41220 { "WRITEPODARRAYRV", 2, 0, 1, 0},
41221 { "WRITEPODARRAYVR", 2, 1, 0, 0},
41222 { "WRITEPODARRAYVV", 2, 1, 1, 0},
41223
41224 { "PRINTFV", 1, 1, 0, 0},
41225 { "SPRINTFV", 1, 1, 0, 0},
41226
41227 { "STRCMPR", 2, 0, 0, 0},
41228 { "STRICMPR", 2, 0, 0, 0},
41229 { "STRINGICOMPARE", 1, 0, 0, 0},
41230 { "STRINGNICOMPARE", 1, 0, 0, 0},
41231
41232 { "FILEREMOVE", 0, 0, 0, 0},
41233 { "FILESYSREMOVE", 1, 0, 0, 0},
41234
41235 { "DRAWSTRINGR2", 0, 0, 0, 0},
41236 { "BMPDRAWSTRINGR2", 0, 0, 0, 0},
41237
41238 { "MODULEGETIC", 2, 0, 0, 0},
41239 { "ITOACAT", 2, 0, 0, 0},
41240
41241 { "FRAMER", 0, 0, 0, 0},
41242 { "BMPFRAMER", 0, 0, 0, 0},
41243
41244 { "LOADDIRECTORYR", 1, 0, 0, 0},
41245 { "DIRECTORYGET", 2, 0, 0, 0},
41246 { "DIRECTORYRELOAD", 0, 0, 0, 0},
41247 { "DIRECTORYFREE", 0, 0, 0, 0},
41248 { "FILEWRITEBYTES", 2, 0, 0, 0},
41249 { "GETCOMBOSCRIPT", 1, 0, 0, 0},
41250 { "FILEREADBYTES", 2, 0, 0, 0},
41251
41252 { "LOADRNG", 0, 0, 0, 0},
41253 { "RNGRAND1", 0, 0, 0, 0},
41254 { "RNGRAND2", 1, 0, 0, 0},
41255 { "RNGRAND3", 2, 0, 0, 0},
41256 { "RNGLRAND1", 0, 0, 0, 0},
41257 { "RNGLRAND2", 1, 0, 0, 0},
41258 { "RNGLRAND3", 2, 0, 0, 0},
41259 { "RNGSEED", 1, 0, 0, 0},
41260 { "RNGRSEED", 0, 0, 0, 0},
41261 { "RNGFREE", 0, 0, 0, 0},
41262 { "LWPNDEL", 0, 0, 0, 0},
41263 { "EWPNDEL", 0, 0, 0, 0},
41264 { "ITEMDEL", 0, 0, 0, 0},
41265 { "BMPWRITETILE", 0, 0, 0, 0},
41266 { "BMPDITHER", 0, 0, 0, 0},
41267 { "BMPREPLCOLOR", 0, 0, 0, 0},
41268 { "BMPSHIFTCOLOR", 0, 0, 0, 0},
41269 { "BMPMASKDRAW", 0, 0, 0, 0},
41270 { "RESIZEARRAYR", 2, 0, 0, 0},
41271 { "BSHOPNAMEGET", 1, 0, 0, 0},
41272 { "BSHOPNAMESET", 1, 0, 0, 0},
41273 { "BOTTLENAMEGET", 1, 0, 0, 0},
41274 { "BOTTLENAMESET", 1, 0, 0, 0},
41275 { "LOADBOTTLETYPE", 1, 0, 0, 0},
41276 { "LOADBSHOPDATA", 1, 0, 0, 0},
41277 { "SWITCHNPC", 1, 0, 0, 0},
41278 { "SWITCHCMB", 2, 0, 0, 0},
41279 { "SWITCHITM", 1, 0, 0, 0},
41280 { "SWITCHLW", 1, 0, 0, 0},
41281 { "SWITCHEW", 1, 0, 0, 0},
41282 { "SCREENDOSPAWN", 0, 0, 0, 0},
41283 { "NPCMOVEPAUSED", 0, 0, 0, 0},
41284 { "NPCMOVE", 0, 0, 0, 0},
41285 { "NPCMOVEANGLE", 0, 0, 0, 0},
41286 { "NPCMOVEXY", 0, 0, 0, 0},
41287 { "NPCCANMOVEDIR", 0, 0, 0, 0},
41288 { "NPCCANMOVEANGLE", 0, 0, 0, 0},
41289 { "NPCCANMOVEXY", 0, 0, 0, 0},
41290 { "SELECTXWPNR", 1, 0, 0, 0},
41291 { "SELECTYWPNR", 1, 0, 0, 0},
41292 { "BITMAPOWN", 0, 0, 0, 0},
41293 { "FILEOWN", 0, 0, 0, 0},
41294 { "DIRECTORYOWN", 0, 0, 0, 0},
41295 { "RNGOWN", 0, 0, 0, 0},
41296 { "LOADGENERICDATA", 1, 0, 0, 0},
41297 { "RUNGENFRZSCR", 1, 0, 0, 0},
41298 { "WAITTO", 2, 0, 0, 0},
41299 { "GETGENERICSCRIPT", 1, 0, 0, 0},
41300 { "KILLPLAYER", 1, 0, 0, 0},
41301 { "DEGTORAD", 2, 0, 0, 0},
41302 { "RADTODEG", 2, 0, 0, 0},
41303 { "LWPNMAKEANGULAR", 1, 0, 0, 0},
41304 { "EWPNMAKEANGULAR", 1, 0, 0, 0},
41305 { "LWPNMAKEDIRECTIONAL", 1, 0, 0, 0},
41306 { "EWPNMAKEDIRECTIONAL", 1, 0, 0, 0},
41307 { "BMPMASKDRAW2", 0, 0, 0, 0},
41308 { "BMPMASKDRAW3", 0, 0, 0, 0},
41309 { "BMPMASKBLIT", 0, 0, 0, 0},
41310 { "BMPMASKBLIT2", 0, 0, 0, 0},
41311 { "BMPMASKBLIT3", 0, 0, 0, 0},
41312 { "SUBV2", 2, 1, 0, 0},
41313 { "DIVV2", 2, 1, 0, 0},
41314 { "COMPAREV2", 2, 1, 0, 0},
41315 { "MODV2", 2, 1, 0, 0},
41316 { "STACKFREE", 0, 0, 0, 0},
41317 { "STACKOWN", 0, 0, 0, 0},
41318 { "STACKGET", 1, 0, 0, 0},
41319 { "STACKSET", 2, 0, 0, 0},
41320 { "STACKPOPBACK", 0, 0, 0, 0},
41321 { "STACKPOPFRONT", 0, 0, 0, 0},
41322 { "STACKPEEKBACK", 0, 0, 0, 0},
41323 { "STACKPEEKFRONT", 0, 0, 0, 0},
41324 { "STACKPUSHBACK", 1, 0, 0, 0},
41325 { "STACKPUSHFRONT", 1, 0, 0, 0},
41326 { "LOADSTACK", 0, 0, 0, 0},
41327 { "STACKCLEAR", 0, 0, 0, 0},
41328 { "POWERV2", 2, 1, 0, 0},
41329 { "LPOWERR", 2, 0, 0, 0},
41330 { "LPOWERV", 2, 0, 1, 0},
41331 { "LPOWERV2", 2, 1, 0, 0},
41332 { "SCRTRIGGERCOMBO", 2, 0, 0, 0},
41333 { "WAITEVENT", 0, 0, 0, 0},
41334 { "OWNARRAYR", 1, 0, 0, 0},
41335 { "DESTROYARRAYR", 1, 0, 0, 0},
41336 { "GRAPHICSCOUNTCOLOR", 1, 0, 0, 0},
41337 { "WRITEPODSTRING", 1, 0, 0, 1},
41338 { "WRITEPODARRAY", 1, 0, 0, 2},
41339 { "ZCLASS_CONSTRUCT", 1, 0, 0, 2},
41340 { "ZCLASS_READ", 2, 0, 1, 0},
41341 { "ZCLASS_WRITE", 2, 0, 1, 0},
41342 { "ZCLASS_FREE", 1, 0, 0, 0},
41343 { "ZCLASS_OWN", 1, 0, 0, 0},
41344 { "STARTDESTRUCTOR", 0, 0, 0, 1},
41345 { "ZCLASS_GLOBALIZE", 1, 0, 0, 0},
41346 { "LOADD", 2, 0, 1, 0},
41347 { "STORED", 2, 0, 1, 0},
41348 { "OBJ_OWN_BITMAP", 2, 0, 1, 0},
41349 { "OBJ_OWN_PALDATA", 2, 0, 1, 0},
41350 { "OBJ_OWN_FILE", 2, 0, 1, 0},
41351 { "OBJ_OWN_DIR", 2, 0, 1, 0},
41352 { "OBJ_OWN_STACK", 2, 0, 1, 0},
41353 { "OBJ_OWN_RNG", 2, 0, 1, 0},
41354 { "OBJ_OWN_CLASS", 2, 0, 1, 0},
41355 { "OBJ_OWN_ARRAY", 2, 0, 1, 0},
41356 { "QUIT_NO_DEALLOC", 0, 0, 0, 0},
41357 { "GAMESETCUSTOMCURSOR", 0, 0, 0, 0},
41358 { "NPCCANPLACE", 0, 0, 0, 0},
41359 { "ITEMGETDISPLAYNAME", 1, 0, 0, 0},
41360 { "ITEMSETDISPLAYNAME", 1, 0, 0, 0},
41361 { "ITEMGETSHOWNNAME", 1, 0, 0, 0},
41362 { "HEROMOVEXY", 0, 0, 0, 0},
41363 { "HEROCANMOVEXY", 0, 0, 0, 0},
41364 { "HEROLIFTRELEASE", 0, 0, 0, 0},
41365 { "HEROLIFTGRAB", 0, 0, 0, 0},
41366 { "LOADPORTAL", 0, 0, 0, 0},
41367 { "CREATEPORTAL", 0, 0, 0, 0},
41368 { "LOADSAVPORTAL", 0, 0, 0, 0},
41369 { "CREATESAVPORTAL", 0, 0, 0, 0},
41370 { "CREATEPALDATA", 0, 0, 0, 0 },
41371 { "CREATEPALDATACLR", 1, 0, 0, 0 },
41372 { "MIXCLR", 0, 0, 0, 0 },
41373 { "CREATERGBHEX", 1, 0, 0, 0 },
41374 { "CREATERGB", 0, 0, 0, 0 },
41375 { "PALDATALOADLEVEL", 1, 0, 0, 0 },
41376 { "PALDATALOADSPRITE", 1, 0, 0, 0 },
41377 { "PALDATALOADMAIN", 0, 0, 0, 0 },
41378 { "PALDATALOADCYCLE", 1, 0, 0, 0 },
41379 { "PALDATALOADBITMAP", 1, 0, 0, 0 },
41380 { "PALDATAWRITELEVEL", 1, 0, 0, 0 },
41381 { "PALDATAWRITELEVELCS", 2, 0, 0, 0 },
41382 { "PALDATAWRITESPRITE", 1, 0, 0, 0 },
41383 { "PALDATAWRITESPRITECS", 2, 0, 0, 0 },
41384 { "PALDATAWRITEMAIN", 0, 0, 0, 0 },
41385 { "PALDATAWRITEMAINCS", 1, 0, 0, 0 },
41386 { "PALDATAWRITECYCLE", 1, 0, 0, 0 },
41387 { "PALDATAWRITECYCLECS", 2, 0, 0, 0 },
41388 { "PALDATAVALIDCLR", 1, 0, 0, 0 },
41389 { "PALDATACLEARCLR", 1, 0, 0, 0 },
41390 { "PALDATACLEARCSET", 1, 0, 0, 0 },
41391 { "PALDATAMIX", 0, 0, 0, 0 },
41392 { "PALDATAMIXCS", 0, 0, 0, 0 },
41393 { "PALDATACOPY", 1, 0, 0, 0 },
41394 { "PALDATACOPYCSET", 0, 0, 0, 0 },
41395 { "PALDATAFREE", 0, 0, 0, 0 },
41396 { "PALDATAOWN", 0, 0, 0, 0 },
41397 { "MAXVARG", 0, 0, 0, 0 },
41398 { "MINVARG", 0, 0, 0, 0 },
41399 { "CHOOSEVARG", 0, 0, 0, 0 },
41400 { "PUSHVARGV", 1, 1, 0, 0 },
41401 { "PUSHVARGR", 1, 0, 0, 0 },
41402 { "PRINTFVARG", 0, 0, 0, 0 },
41403 { "SPRINTFVARG", 0, 0, 0, 0 },
41404 { "TRACELR", 1, 0, 0, 0 },
41405 { "WAITFRAMESR", 1, 0, 0, 0 },
41406 { "RESRVD_OP_Z3_01", 0, 0, 0, 0 },
41407 { "RESRVD_OP_Z3_02", 0, 0, 0, 0 },
41408 { "RESRVD_OP_Z3_03", 0, 0, 0, 0 },
41409 { "RESRVD_OP_Z3_04", 0, 0, 0, 0 },
41410 { "RESRVD_OP_Z3_05", 0, 0, 0, 0 },
41411 { "RESRVD_OP_Z3_06", 0, 0, 0, 0 },
41412 { "RESRVD_OP_Z3_07", 0, 0, 0, 0 },
41413 { "RESRVD_OP_Z3_08", 0, 0, 0, 0 },
41414 { "RESRVD_OP_Z3_09", 0, 0, 0, 0 },
41415 { "RESRVD_OP_Z3_10", 0, 0, 0, 0 },
41416 { "PORTALREMOVE", 0, 0, 0, 0 },
41417 { "SAVEDPORTALREMOVE", 0, 0, 0, 0 },
41418 { "SAVEDPORTALGENERATE", 0, 0, 0, 0 },
41419 { "PORTALUSESPRITE", 1, 0, 0, 0 },
41420 { "HEROMOVEATANGLE", 0, 0, 0, 0 },
41421 { "HEROCANMOVEATANGLE", 0, 0, 0, 0 },
41422 { "HEROMOVE", 0, 0, 0, 0 },
41423 { "HEROCANMOVE", 0, 0, 0, 0 },
41424 { "DRAWLIGHT_CIRCLE", 0, 0, 0, 0 },
41425 { "DRAWLIGHT_SQUARE", 0, 0, 0, 0 },
41426 { "DRAWLIGHT_CONE", 0, 0, 0, 0 },
41427 { "PEEK", 1, 0, 0, 0 },
41428 { "RESRVD_OP_EMILY_10", 0, 0, 0, 0 },
41429 { "RESRVD_OP_EMILY_11", 0, 0, 0, 0 },
41430 { "RESRVD_OP_EMILY_12", 0, 0, 0, 0 },
41431 { "RESRVD_OP_EMILY_13", 0, 0, 0, 0 },
41432 { "RESRVD_OP_EMILY_14", 0, 0, 0, 0 },
41433 { "RESRVD_OP_EMILY_15", 0, 0, 0, 0 },
41434 { "RESRVD_OP_EMILY_16", 0, 0, 0, 0 },
41435 { "RESRVD_OP_EMILY_17", 0, 0, 0, 0 },
41436 { "RESRVD_OP_EMILY_18", 0, 0, 0, 0 },
41437 { "RESRVD_OP_EMILY_19", 0, 0, 0, 0 },
41438 { "RESRVD_OP_EMILY_20", 0, 0, 0, 0 },
41439 { "CONVERTFROMRGB", 0, 0, 0, 0 },
41440 { "CONVERTTORGB", 0, 0, 0, 0 },
41441 { "GETENHMUSICLEN", 1, 0, 0, 0 },
41442 { "SETENHMUSICLOOP", 2, 0, 0, 0 },
41443 { "PLAYSOUNDEX", 0, 0, 0, 0 },
41444 { "GETSFXCOMPLETION", 1, 0, 0, 0 },
41445 { "ENHCROSSFADE", 0, 0, 0, 0 },
41446 { "RESRVD_OP_MOOSH_08", 0, 0, 0, 0 },
41447 { "RESRVD_OP_MOOSH_09", 0, 0, 0, 0 },
41448 { "RESRVD_OP_MOOSH_10", 0, 0, 0, 0 },
41449
41450 { "", 0, 0, 0, 0}
41451 };
41452
41453
41454 script_variable ZASMVars[]=
41455 {
41456 //name id maxcount multiple
41457 { "D", D(0), 8, 0 },
41458 { "A", A(0), 2, 0 },
41459 { "DATA", DATA, 0, 0 },
41460 { "CSET", FCSET, 0, 0 },
41461 { "DELAY", DELAY, 0, 0 },
41462 { "X", FX, 0, 0 },
41463 { "Y", FY, 0, 0 },
41464 { "XD", XD, 0, 0 },
41465 { "YD", YD, 0, 0 },
41466 { "XD2", XD2, 0, 0 },
41467 { "YD2", YD2, 0, 0 },
41468 { "FLAG", FLAG, 0, 0 },
41469 { "WIDTH", WIDTH, 0, 0 },
41470 { "HEIGHT", HEIGHT, 0, 0 },
41471 { "LINK", LINK, 0, 0 },
41472 { "FFFLAGSD", FFFLAGSD, 0, 0 },
41473 { "FFCWIDTH", FFCWIDTH, 0, 0 },
41474 { "FFCHEIGHT", FFCHEIGHT, 0, 0 },
41475 { "FFTWIDTH", FFTWIDTH, 0, 0 },
41476 { "FFTHEIGHT", FFTHEIGHT, 0, 0 },
41477 { "FFLINK", FFLINK, 0, 0 },
41478 // { "COMBOD", COMBOD(0), 176, 3 },
41479 // { "COMBOC", COMBOC(0), 176, 3 },
41480 // { "COMBOF", COMBOF(0), 176, 3 },
41481 { "INPUTSTART", INPUTSTART, 0, 0 },
41482 { "INPUTUP", INPUTUP, 0, 0 },
41483 { "INPUTDOWN", INPUTDOWN, 0, 0 },
41484 { "INPUTLEFT", INPUTLEFT, 0, 0 },
41485 { "INPUTRIGHT", INPUTRIGHT, 0, 0 },
41486 { "INPUTA", INPUTA, 0, 0 },
41487 { "INPUTB", INPUTB, 0, 0 },
41488 { "INPUTL", INPUTL, 0, 0 },
41489 { "INPUTR", INPUTR, 0, 0 },
41490 { "INPUTMOUSEX", INPUTMOUSEX, 0, 0 },
41491 { "INPUTMOUSEY", INPUTMOUSEY, 0, 0 },
41492 { "LINKX", LINKX, 0, 0 },
41493 { "LINKY", LINKY, 0, 0 },
41494 { "LINKZ", LINKZ, 0, 0 },
41495 { "LINKJUMP", LINKJUMP, 0, 0 },
41496 { "LINKDIR", LINKDIR, 0, 0 },
41497 { "LINKHITDIR", LINKHITDIR, 0, 0 },
41498 { "LINKHP", LINKHP, 0, 0 },
41499 { "LINKMP", LINKMP, 0, 0 },
41500 { "LINKMAXHP", LINKMAXHP, 0, 0 },
41501 { "LINKMAXMP", LINKMAXMP, 0, 0 },
41502 { "LINKACTION", LINKACTION, 0, 0 },
41503 { "LINKHELD", LINKHELD, 0, 0 },
41504 { "LINKITEMD", LINKITEMD, 0, 0 },
41505 { "LINKSWORDJINX", LINKSWORDJINX, 0, 0 },
41506 { "LINKITEMJINX", LINKITEMJINX, 0, 0 },
41507 { "LINKDRUNK", LINKDRUNK, 0, 0 },
41508 { "ITEMX", ITEMX, 0, 0 },
41509 { "ITEMY", ITEMY, 0, 0 },
41510 { "ITEMZ", ITEMZ, 0, 0 },
41511 { "ITEMJUMP", ITEMJUMP, 0, 0 },
41512 { "ITEMDRAWTYPE", ITEMDRAWTYPE, 0, 0 },
41513 { "ITEMID", ITEMID, 0, 0 },
41514 { "ITEMTILE", ITEMTILE, 0, 0 },
41515 { "ITEMOTILE", ITEMOTILE, 0, 0 },
41516 { "ITEMCSET", ITEMCSET, 0, 0 },
41517 { "ITEMFLASHCSET", ITEMFLASHCSET, 0, 0 },
41518 { "ITEMFRAMES", ITEMFRAMES, 0, 0 },
41519 { "ITEMFRAME", ITEMFRAME, 0, 0 },
41520 { "ITEMASPEED", ITEMASPEED, 0, 0 },
41521 { "ITEMDELAY", ITEMDELAY, 0, 0 },
41522 { "ITEMFLASH", ITEMFLASH, 0, 0 },
41523 { "ITEMFLIP", ITEMFLIP, 0, 0 },
41524 { "ITEMCOUNT", ITEMCOUNT, 0, 0 },
41525 { "IDATAFAMILY", IDATAFAMILY, 0, 0 },
41526 { "IDATALEVEL", IDATALEVEL, 0, 0 },
41527 { "IDATAKEEP", IDATAKEEP, 0, 0 },
41528 { "IDATAAMOUNT", IDATAAMOUNT, 0, 0 },
41529 { "IDATASETMAX", IDATASETMAX, 0, 0 },
41530 { "IDATAMAX", IDATAMAX, 0, 0 },
41531 { "IDATACOUNTER", IDATACOUNTER, 0, 0 },
41532 { "ITEMEXTEND", ITEMEXTEND, 0, 0 },
41533 { "NPCX", NPCX, 0, 0 },
41534 { "NPCY", NPCY, 0, 0 },
41535 { "NPCZ", NPCZ, 0, 0 },
41536 { "NPCJUMP", NPCJUMP, 0, 0 },
41537 { "NPCDIR", NPCDIR, 0, 0 },
41538 { "NPCRATE", NPCRATE, 0, 0 },
41539 { "NPCSTEP", NPCSTEP, 0, 0 },
41540 { "NPCFRAMERATE", NPCFRAMERATE, 0, 0 },
41541 { "NPCHALTRATE", NPCHALTRATE, 0, 0 },
41542 { "NPCDRAWTYPE", NPCDRAWTYPE, 0, 0 },
41543 { "NPCHP", NPCHP, 0, 0 },
41544 { "NPCID", NPCID, 0, 0 },
41545 { "NPCDP", NPCDP, 0, 0 },
41546 { "NPCWDP", NPCWDP, 0, 0 },
41547 { "NPCOTILE", NPCOTILE, 0, 0 },
41548 { "NPCENEMY", NPCENEMY, 0, 0 },
41549 { "NPCWEAPON", NPCWEAPON, 0, 0 },
41550 { "NPCITEMSET", NPCITEMSET, 0, 0 },
41551 { "NPCCSET", NPCCSET, 0, 0 },
41552 { "NPCBOSSPAL", NPCBOSSPAL, 0, 0 },
41553 { "NPCBGSFX", NPCBGSFX, 0, 0 },
41554 { "NPCCOUNT", NPCCOUNT, 0, 0 },
41555 { "GD", GD(0), 1024, 0 },
41556 { "SDD", SDD, 0, 0 },
41557 { "GDD", GDD, 0, 0 },
41558 { "SDDD", SDDD, 0, 0 },
41559 { "SCRDOORD", SCRDOORD, 0, 0 },
41560 { "GAMEDEATHS", GAMEDEATHS, 0, 0 },
41561 { "GAMECHEAT", GAMECHEAT, 0, 0 },
41562 { "GAMETIME", GAMETIME, 0, 0 },
41563 { "GAMEHASPLAYED", GAMEHASPLAYED, 0, 0 },
41564 { "GAMETIMEVALID", GAMETIMEVALID, 0, 0 },
41565 { "GAMEGUYCOUNT", GAMEGUYCOUNT, 0, 0 },
41566 { "GAMECONTSCR", GAMECONTSCR, 0, 0 },
41567 { "GAMECONTDMAP", GAMECONTDMAP, 0, 0 },
41568 { "GAMECOUNTERD", GAMECOUNTERD, 0, 0 },
41569 { "GAMEMCOUNTERD", GAMEMCOUNTERD, 0, 0 },
41570 { "GAMEDCOUNTERD", GAMEDCOUNTERD, 0, 0 },
41571 { "GAMEGENERICD", GAMEGENERICD, 0, 0 },
41572 { "GAMEMISC", GAMEMISC, 0, 0 },
41573 { "GAMEITEMSD", GAMEITEMSD, 0, 0 },
41574 { "GAMELITEMSD", GAMELITEMSD, 0, 0 },
41575 { "GAMELKEYSD", GAMELKEYSD, 0, 0 },
41576 { "SCREENSTATED", SCREENSTATED, 0, 0 },
41577 { "SCREENSTATEDD", SCREENSTATEDD, 0, 0 },
41578 { "GAMEGUYCOUNTD", GAMEGUYCOUNTD, 0, 0 },
41579 { "CURMAP", CURMAP, 0, 0 },
41580 { "CURSCR", CURSCR, 0, 0 },
41581 { "CURDSCR", CURDSCR, 0, 0 },
41582 { "CURDMAP", CURDMAP, 0, 0 },
41583 { "COMBODD", COMBODD, 0, 0 },
41584 { "COMBOCD", COMBOCD, 0, 0 },
41585 { "COMBOFD", COMBOFD, 0, 0 },
41586 { "COMBOTD", COMBOTD, 0, 0 },
41587 { "COMBOID", COMBOID, 0, 0 },
41588 { "COMBOSD", COMBOSD, 0, 0 },
41589 { "REFITEMCLASS", REFITEMCLASS, 0, 0 },
41590 { "REFITEM", REFITEM, 0, 0 },
41591 { "REFFFC", REFFFC, 0, 0 },
41592 { "REFLWPN", REFLWPN, 0, 0 },
41593 { "REFEWPN", REFEWPN, 0, 0 },
41594 { "REFLWPNCLASS", REFLWPNCLASS, 0, 0 },
41595 { "REFEWPNCLASS", REFEWPNCLASS, 0, 0 },
41596 { "REFNPC", REFNPC, 0, 0 },
41597 { "REFNPCCLASS", REFNPCCLASS, 0, 0 },
41598 { "LWPNX", LWPNX, 0, 0 },
41599 { "LWPNY", LWPNY, 0, 0 },
41600 { "LWPNZ", LWPNZ, 0, 0 },
41601 { "LWPNJUMP", LWPNJUMP, 0, 0 },
41602 { "LWPNDIR", LWPNDIR, 0, 0 },
41603 { "LWPNSTEP", LWPNSTEP, 0, 0 },
41604 { "LWPNANGULAR", LWPNANGULAR, 0, 0 },
41605 { "LWPNANGLE", LWPNANGLE, 0, 0 },
41606 { "LWPNDRAWTYPE", LWPNDRAWTYPE, 0, 0 },
41607 { "LWPNPOWER", LWPNPOWER, 0, 0 },
41608 { "LWPNDEAD", LWPNDEAD, 0, 0 },
41609 { "LWPNID", LWPNID, 0, 0 },
41610 { "LWPNTILE", LWPNTILE, 0, 0 },
41611 { "LWPNCSET", LWPNCSET, 0, 0 },
41612 { "LWPNFLASHCSET", LWPNFLASHCSET, 0, 0 },
41613 { "LWPNFRAMES", LWPNFRAMES, 0, 0 },
41614 { "LWPNFRAME", LWPNFRAME, 0, 0 },
41615 { "LWPNASPEED", LWPNASPEED, 0, 0 },
41616 { "LWPNFLASH", LWPNFLASH, 0, 0 },
41617 { "LWPNFLIP", LWPNFLIP, 0, 0 },
41618 { "LWPNCOUNT", LWPNCOUNT, 0, 0 },
41619 { "LWPNEXTEND", LWPNEXTEND, 0, 0 },
41620 { "LWPNOTILE", LWPNOTILE, 0, 0 },
41621 { "LWPNOCSET", LWPNOCSET, 0, 0 },
41622 { "EWPNX", EWPNX, 0, 0 },
41623 { "EWPNY", EWPNY, 0, 0 },
41624 { "EWPNZ", EWPNZ, 0, 0 },
41625 { "EWPNJUMP", EWPNJUMP, 0, 0 },
41626 { "EWPNDIR", EWPNDIR, 0, 0 },
41627 { "EWPNSTEP", EWPNSTEP, 0, 0 },
41628 { "EWPNANGULAR", EWPNANGULAR, 0, 0 },
41629 { "EWPNANGLE", EWPNANGLE, 0, 0 },
41630 { "EWPNDRAWTYPE", EWPNDRAWTYPE, 0, 0 },
41631 { "EWPNPOWER", EWPNPOWER, 0, 0 },
41632 { "EWPNDEAD", EWPNDEAD, 0, 0 },
41633 { "EWPNID", EWPNID, 0, 0 },
41634 { "EWPNTILE", EWPNTILE, 0, 0 },
41635 { "EWPNCSET", EWPNCSET, 0, 0 },
41636 { "EWPNFLASHCSET", EWPNFLASHCSET, 0, 0 },
41637 { "EWPNFRAMES", EWPNFRAMES, 0, 0 },
41638 { "EWPNFRAME", EWPNFRAME, 0, 0 },
41639 { "EWPNASPEED", EWPNASPEED, 0, 0 },
41640 { "EWPNFLASH", EWPNFLASH, 0, 0 },
41641 { "EWPNFLIP", EWPNFLIP, 0, 0 },
41642 { "EWPNCOUNT", EWPNCOUNT, 0, 0 },
41643 { "EWPNEXTEND", EWPNEXTEND, 0, 0 },
41644 { "EWPNOTILE", EWPNOTILE, 0, 0 },
41645 { "EWPNOCSET", EWPNOCSET, 0, 0 },
41646 { "NPCEXTEND", NPCEXTEND, 0, 0 },
41647 { "SP", SP, 0, 0 },
41648 { "SP", SP, 0, 0 },
41649 { "WAVY", WAVY, 0, 0 },
41650 { "QUAKE", QUAKE, 0, 0 },
41651 { "IDATAUSESOUND", IDATAUSESOUND, 0, 0 },
41652 { "INPUTMOUSEZ", INPUTMOUSEZ, 0, 0 },
41653 { "INPUTMOUSEB", INPUTMOUSEB, 0, 0 },
41654 { "COMBODDM", COMBODDM, 0, 0 },
41655 { "COMBOCDM", COMBOCDM, 0, 0 },
41656 { "COMBOFDM", COMBOFDM, 0, 0 },
41657 { "COMBOTDM", COMBOTDM, 0, 0 },
41658 { "COMBOIDM", COMBOIDM, 0, 0 },
41659 { "COMBOSDM", COMBOSDM, 0, 0 },
41660 { "SCRIPTRAM", SCRIPTRAM, 0, 0 },
41661 { "GLOBALRAM", GLOBALRAM, 0, 0 },
41662 { "SCRIPTRAMD", SCRIPTRAMD, 0, 0 },
41663 { "GLOBALRAMD", GLOBALRAMD, 0, 0 },
41664 { "LWPNHXOFS", LWPNHXOFS, 0, 0 },
41665 { "LWPNHYOFS", LWPNHYOFS, 0, 0 },
41666 { "LWPNXOFS", LWPNXOFS, 0, 0 },
41667 { "LWPNYOFS", LWPNYOFS, 0, 0 },
41668 { "LWPNZOFS", LWPNZOFS, 0, 0 },
41669 { "LWPNHXSZ", LWPNHXSZ, 0, 0 },
41670 { "LWPNHYSZ", LWPNHYSZ, 0, 0 },
41671 { "LWPNHZSZ", LWPNHZSZ, 0, 0 },
41672 { "EWPNHXOFS", EWPNHXOFS, 0, 0 },
41673 { "EWPNHYOFS", EWPNHYOFS, 0, 0 },
41674 { "EWPNXOFS", EWPNXOFS, 0, 0 },
41675 { "EWPNYOFS", EWPNYOFS, 0, 0 },
41676 { "EWPNZOFS", EWPNZOFS, 0, 0 },
41677 { "EWPNHXSZ", EWPNHXSZ, 0, 0 },
41678 { "EWPNHYSZ", EWPNHYSZ, 0, 0 },
41679 { "EWPNHZSZ", EWPNHZSZ, 0, 0 },
41680 { "NPCHXOFS", NPCHXOFS, 0, 0 },
41681 { "NPCHYOFS", NPCHYOFS, 0, 0 },
41682 { "NPCXOFS", NPCXOFS, 0, 0 },
41683 { "NPCYOFS", NPCYOFS, 0, 0 },
41684 { "NPCZOFS", NPCZOFS, 0, 0 },
41685 { "NPCHXSZ", NPCHXSZ, 0, 0 },
41686 { "NPCHYSZ", NPCHYSZ, 0, 0 },
41687 { "NPCHZSZ", NPCHZSZ, 0, 0 },
41688 { "ITEMHXOFS", ITEMHXOFS, 0, 0 },
41689 { "ITEMHYOFS", ITEMHYOFS, 0, 0 },
41690 { "ITEMXOFS", ITEMXOFS, 0, 0 },
41691 { "ITEMYOFS", ITEMYOFS, 0, 0 },
41692 { "ITEMZOFS", ITEMZOFS, 0, 0 },
41693 { "ITEMHXSZ", ITEMHXSZ, 0, 0 },
41694 { "ITEMHYSZ", ITEMHYSZ, 0, 0 },
41695 { "ITEMHZSZ", ITEMHZSZ, 0, 0 },
41696 { "LWPNTXSZ", LWPNTXSZ, 0, 0 },
41697 { "LWPNTYSZ", LWPNTYSZ, 0, 0 },
41698 { "EWPNTXSZ", EWPNTXSZ, 0, 0 },
41699 { "EWPNTYSZ", EWPNTYSZ, 0, 0 },
41700 { "NPCTXSZ", NPCTXSZ, 0, 0 },
41701 { "NPCTYSZ", NPCTYSZ, 0, 0 },
41702 { "ITEMTXSZ", ITEMTXSZ, 0, 0 },
41703 { "ITEMTYSZ", ITEMTYSZ, 0, 0 },
41704 { "LINKHXOFS", LINKHXOFS, 0, 0 },
41705 { "LINKHYOFS", LINKHYOFS, 0, 0 },
41706 { "LINKXOFS", LINKXOFS, 0, 0 },
41707 { "LINKYOFS", LINKYOFS, 0, 0 },
41708 { "LINKZOFS", LINKZOFS, 0, 0 },
41709 { "LINKHXSZ", LINKHXSZ, 0, 0 },
41710 { "LINKHYSZ", LINKHYSZ, 0, 0 },
41711 { "LINKHZSZ", LINKHZSZ, 0, 0 },
41712 { "LINKTXSZ", LINKTXSZ, 0, 0 },
41713 { "LINKTYSZ", LINKTYSZ, 0, 0 },
41714 { "NPCTILE", NPCTILE, 0, 0 },
41715 { "LWPNBEHIND", LWPNBEHIND, 0, 0 },
41716 { "EWPNBEHIND", EWPNBEHIND, 0, 0 },
41717 { "SDDDD", SDDDD, 0, 0 },
41718 { "CURLEVEL", CURLEVEL, 0, 0 },
41719 { "ITEMPICKUP", ITEMPICKUP, 0, 0 },
41720 { "INPUTMAP", INPUTMAP, 0, 0 },
41721 { "LIT", LIT, 0, 0 },
41722 { "INPUTEX1", INPUTEX1, 0, 0 },
41723 { "INPUTEX2", INPUTEX2, 0, 0 },
41724 { "INPUTEX3", INPUTEX3, 0, 0 },
41725 { "INPUTEX4", INPUTEX4, 0, 0 },
41726 { "INPUTPRESSSTART", INPUTPRESSSTART, 0, 0 },
41727 { "INPUTPRESSUP", INPUTPRESSUP, 0, 0 },
41728 { "INPUTPRESSDOWN", INPUTPRESSDOWN, 0, 0 },
41729 { "INPUTPRESSLEFT", INPUTPRESSLEFT, 0, 0 },
41730 { "INPUTPRESSRIGHT", INPUTPRESSRIGHT, 0, 0 },
41731 { "INPUTPRESSA", INPUTPRESSA, 0, 0 },
41732 { "INPUTPRESSB", INPUTPRESSB, 0, 0 },
41733 { "INPUTPRESSL", INPUTPRESSL, 0, 0 },
41734 { "INPUTPRESSR", INPUTPRESSR, 0, 0 },
41735 { "INPUTPRESSEX1", INPUTPRESSEX1, 0, 0 },
41736 { "INPUTPRESSEX2", INPUTPRESSEX2, 0, 0 },
41737 { "INPUTPRESSEX3", INPUTPRESSEX3, 0, 0 },
41738 { "INPUTPRESSEX4", INPUTPRESSEX4, 0, 0 },
41739 { "LWPNMISCD", LWPNMISCD, 0, 0 },
41740 { "EWPNMISCD", EWPNMISCD, 0, 0 },
41741 { "NPCMISCD", NPCMISCD, 0, 0 },
41742 { "ITEMMISCD", ITEMMISCD, 0, 0 },
41743 { "FFMISCD", FFMISCD, 0, 0 },
41744 { "GETMIDI", GETMIDI, 0, 0 },
41745 { "NPCHOMING", NPCHOMING, 0, 0 },
41746 { "NPCDD", NPCDD, 0, 0 },
41747 { "LINKEQUIP", LINKEQUIP, 0, 0 },
41748 { "INPUTAXISUP", INPUTAXISUP, 0, 0 },
41749 { "INPUTAXISDOWN", INPUTAXISDOWN, 0, 0 },
41750 { "INPUTAXISLEFT", INPUTAXISLEFT, 0, 0 },
41751 { "INPUTAXISRIGHT", INPUTAXISRIGHT, 0, 0 },
41752 { "PRESSAXISUP", INPUTPRESSAXISUP, 0, 0 },
41753 { "PRESSAXISDOWN", INPUTPRESSAXISDOWN, 0, 0 },
41754 { "PRESSAXISLEFT", INPUTPRESSAXISLEFT, 0, 0 },
41755 { "PRESSAXISRIGHT", INPUTPRESSAXISRIGHT, 0, 0 },
41756 { "NPCTYPE", NPCTYPE, 0, 0 },
41757 { "FFSCRIPT", FFSCRIPT, 0, 0 },
41758 { "SCREENFLAGSD", SCREENFLAGSD, 0, 0 },
41759 { "LINKINVIS", LINKINVIS, 0, 0 },
41760 { "LINKINVINC", LINKINVINC, 0, 0 },
41761 { "SCREENEFLAGSD", SCREENEFLAGSD, 0, 0 },
41762 { "NPCMFLAGS", NPCMFLAGS, 0, 0 },
41763 { "FFINITDD", FFINITDD, 0, 0 },
41764 { "LINKMISCD", LINKMISCD, 0, 0 },
41765 { "DMAPFLAGSD", DMAPFLAGSD, 0, 0 },
41766 { "LWPNCOLLDET", LWPNCOLLDET, 0, 0 },
41767 { "EWPNCOLLDET", EWPNCOLLDET, 0, 0 },
41768 { "NPCCOLLDET", NPCCOLLDET, 0, 0 },
41769 { "LINKLADDERX", LINKLADDERX, 0, 0 },
41770 { "LINKLADDERY", LINKLADDERY, 0, 0 },
41771 { "NPCSTUN", NPCSTUN, 0, 0 },
41772 { "NPCDEFENSED", NPCDEFENSED, 0, 0 },
41773 { "IDATAPOWER", IDATAPOWER, 0, 0 },
41774 { "DMAPLEVELD", DMAPLEVELD, 0, 0 },
41775 { "DMAPCOMPASSD", DMAPCOMPASSD, 0, 0 },
41776 { "DMAPCONTINUED", DMAPCONTINUED, 0, 0 },
41777 { "DMAPMIDID", DMAPMIDID, 0, 0 },
41778 { "IDATAINITDD", IDATAINITDD, 0, 0 },
41779 { "ROOMTYPE", ROOMTYPE, 0, 0 },
41780 { "ROOMDATA", ROOMDATA, 0, 0 },
41781 { "LINKTILE", LINKTILE, 0, 0 },
41782 { "LINKFLIP", LINKFLIP, 0, 0 },
41783 { "INPUTPRESSMAP", INPUTPRESSMAP, 0, 0 },
41784 { "NPCHUNGER", NPCHUNGER, 0, 0 },
41785 { "GAMESTANDALONE", GAMESTANDALONE, 0, 0 },
41786 { "GAMEENTRSCR", GAMEENTRSCR, 0, 0 },
41787 { "GAMEENTRDMAP", GAMEENTRDMAP, 0, 0 },
41788 { "GAMECLICKFREEZE", GAMECLICKFREEZE, 0, 0 },
41789 { "PUSHBLOCKX", PUSHBLOCKX, 0, 0 },
41790 { "PUSHBLOCKY", PUSHBLOCKY, 0, 0 },
41791 { "PUSHBLOCKCOMBO", PUSHBLOCKCOMBO, 0, 0 },
41792 { "PUSHBLOCKCSET", PUSHBLOCKCSET, 0, 0 },
41793 { "UNDERCOMBO", UNDERCOMBO, 0, 0 },
41794 { "UNDERCSET", UNDERCSET, 0, 0 },
41795 { "DMAPOFFSET", DMAPOFFSET, 0, 0 },
41796 { "DMAPMAP", DMAPMAP, 0, 0 },
41797 { "__RESERVED_FOR_GAMETHROTTLE", __RESERVED_FOR_GAMETHROTTLE, 0, 0 },
41798 { "REFMAPDATA", REFMAPDATA, 0, 0 },
41799 { "REFSCREENDATA", REFSCREENDATA, 0, 0 },
41800 { "REFCOMBODATA", REFCOMBODATA, 0, 0 },
41801 { "REFSPRITEDATA", REFSPRITEDATA, 0, 0 },
41802 { "REFBITMAP", REFBITMAP, 0, 0 },
41803 { "REFDMAPDATA", REFDMAPDATA, 0, 0 },
41804 { "REFSHOPDATA", REFSHOPDATA, 0, 0 },
41805 { "REFMSGDATA", REFMSGDATA, 0, 0 },
41806 { "REFUNTYPED", REFUNTYPED, 0, 0 },
41807 { "REFDROPS", REFDROPS, 0, 0 },
41808 { "REFPONDS", REFPONDS, 0, 0 },
41809 { "REFWARPRINGS", REFWARPRINGS, 0, 0 },
41810 { "REFDOORS", REFDOORS, 0, 0 },
41811 { "REFUICOLOURS", REFUICOLOURS, 0, 0 },
41812 { "REFRGB", REFRGB, 0, 0 },
41813 { "REFPALETTE", REFPALETTE, 0, 0 },
41814 { "REFTUNES", REFTUNES, 0, 0 },
41815 { "REFPALCYCLE", REFPALCYCLE, 0, 0 },
41816 { "REFGAMEDATA", REFGAMEDATA, 0, 0 },
41817 { "REFCHEATS", REFCHEATS, 0, 0 },
41818 { "IDATAMAGICTIMER", IDATAMAGICTIMER, 0, 0 },
41819 { "IDATALTM", IDATALTM, 0, 0 },
41820 { "IDATASCRIPT", IDATASCRIPT, 0, 0 },
41821 { "IDATAPSCRIPT", IDATAPSCRIPT, 0, 0 },
41822 { "IDATAMAGCOST", IDATAMAGCOST, 0, 0 },
41823 { "IDATAMINHEARTS", IDATAMINHEARTS, 0, 0 },
41824 { "IDATATILE", IDATATILE, 0, 0 },
41825 { "IDATAMISC", IDATAMISC, 0, 0 },
41826 { "IDATACSET", IDATACSET, 0, 0 },
41827 { "IDATAFRAMES", IDATAFRAMES, 0, 0 },
41828 { "IDATAASPEED", IDATAASPEED, 0, 0 },
41829 { "IDATADELAY", IDATADELAY, 0, 0 },
41830 { "IDATACOMBINE", IDATACOMBINE, 0, 0 },
41831 { "IDATADOWNGRADE", IDATADOWNGRADE, 0, 0 },
41832 { "IDATAPSTRING", IDATAPSTRING, 0, 0 },
41833 { "IDATAPFLAGS", IDATAPFLAGS, 0, 0 },
41834 { "IDATAKEEPOLD", IDATAKEEPOLD, 0, 0 },
41835 { "IDATARUPEECOST", IDATARUPEECOST, 0, 0 },
41836 { "IDATAEDIBLE", IDATAEDIBLE, 0, 0 },
41837 { "IDATAFLAGUNUSED", IDATAFLAGUNUSED, 0, 0 },
41838 { "IDATAGAINLOWER", IDATAGAINLOWER, 0, 0 },
41839 { "RESVD0024", RESVD024, 0, 0 },
41840 { "RESVD0025", RESVD025, 0, 0 },
41841 { "RESVD0026", RESVD026, 0, 0 },
41842 { "IDATAID", IDATAID, 0, 0 },
41843 { "__RESERVED_FOR_LINKEXTEND", __RESERVED_FOR_LINKEXTEND, 0, 0 },
41844 { "NPCSCRDEFENSED", NPCSCRDEFENSED, 0, 0 },
41845 { "__RESERVED_FOR_SETLINKTILE", __RESERVED_FOR_SETLINKTILE, 0, 0 },
41846 { "__RESERVED_FOR_SETLINKEXTEND", __RESERVED_FOR_SETLINKEXTEND, 0, 0 },
41847 { "__RESERVED_FOR_SIDEWARPSFX", __RESERVED_FOR_SIDEWARPSFX, 0, 0 },
41848 { "__RESERVED_FOR_PITWARPSFX", __RESERVED_FOR_PITWARPSFX, 0, 0 },
41849 { "__RESERVED_FOR_SIDEWARPVISUAL", __RESERVED_FOR_SIDEWARPVISUAL, 0, 0 },
41850 { "__RESERVED_FOR_PITWARPVISUAL", __RESERVED_FOR_PITWARPVISUAL, 0, 0 },
41851 { "GAMESETA", GAMESETA, 0, 0 },
41852 { "GAMESETB", GAMESETB, 0, 0 },
41853 { "SETITEMSLOT", SETITEMSLOT, 0, 0 },
41854 { "LINKITEMB", LINKITEMB, 0, 0 },
41855 { "LINKITEMA", LINKITEMA, 0, 0 },
41856 { "__RESERVED_FOR_LINKWALKTILE", __RESERVED_FOR_LINKWALKTILE, 0, 0 }, //Walk sprite
41857 { "__RESERVED_FOR_LINKFLOATTILE", __RESERVED_FOR_LINKFLOATTILE, 0, 0 }, //float sprite
41858 { "__RESERVED_FOR_LINKSWIMTILE", __RESERVED_FOR_LINKSWIMTILE, 0, 0 }, //swim sprite
41859 { "__RESERVED_FOR_LINKDIVETILE", __RESERVED_FOR_LINKDIVETILE, 0, 0 }, //dive sprite
41860 { "__RESERVED_FOR_LINKSLASHTILE", __RESERVED_FOR_LINKSLASHTILE, 0, 0 }, //slash sprite
41861 { "__RESERVED_FOR_LINKJUMPTILE", __RESERVED_FOR_LINKJUMPTILE, 0, 0 }, //jump sprite
41862 { "__RESERVED_FOR_LINKCHARGETILE", __RESERVED_FOR_LINKCHARGETILE, 0, 0 }, //charge sprite
41863 { "__RESERVED_FOR_LINKSTABTILE", __RESERVED_FOR_LINKSTABTILE, 0, 0 }, //stab sprite
41864 { "__RESERVED_FOR_LINKCASTTILE", __RESERVED_FOR_LINKCASTTILE, 0, 0 }, //casting sprite
41865 { "__RESERVED_FOR_LINKHOLD1LTILE", __RESERVED_FOR_LINKHOLD1LTILE, 0, 0 }, //hold1land sprite
41866 { "__RESERVED_FOR_LINKHOLD2LTILE", __RESERVED_FOR_LINKHOLD2LTILE, 0, 0 }, //hold2land sprite
41867 { "__RESERVED_FOR_LINKHOLD1WTILE", __RESERVED_FOR_LINKHOLD1WTILE, 0, 0 }, //hold1water sprite
41868 { "__RESERVED_FOR_LINKHOLD2WTILE", __RESERVED_FOR_LINKHOLD2WTILE, 0, 0 }, //hold2water sprite
41869 { "__RESERVED_FOR_LINKPOUNDTILE", __RESERVED_FOR_LINKPOUNDTILE, 0, 0 }, //hammer pound sprite
41870 { "__RESERVED_FOR_LINKSWIMSPD", __RESERVED_FOR_LINKSWIMSPD, 0, 0 },
41871 { "__RESERVED_FOR_LINKWALKANMSPD", __RESERVED_FOR_LINKWALKANMSPD, 0, 0 },
41872 { "__RESERVED_FOR_LINKANIMTYPE", __RESERVED_FOR_LINKANIMTYPE, 0, 0 },
41873 { "LINKINVFRAME", LINKINVFRAME, 0, 0 },
41874 { "LINKCANFLICKER", LINKCANFLICKER, 0, 0 },
41875 { "LINKHURTSFX", LINKHURTSFX, 0, 0 },
41876 { "NOACTIVESUBSC", NOACTIVESUBSC, 0, 0 },
41877 { "LWPNRANGE", LWPNRANGE, 0, 0 },
41878 { "ZELDAVERSION", ZELDAVERSION, 0, 0 },
41879 { "ZELDABUILD", ZELDABUILD, 0, 0 },
41880 { "ZELDABETA", ZELDABETA, 0, 0 },
41881 { "NPCINVINC", NPCINVINC, 0, 0 },
41882 { "NPCSUPERMAN", NPCSUPERMAN, 0, 0 },
41883 { "NPCHASITEM", NPCHASITEM, 0, 0 },
41884 { "NPCRINGLEAD", NPCRINGLEAD, 0, 0 },
41885 { "IDATAFRAME", IDATAFRAME, 0, 0 },
41886 { "ITEMACLK", ITEMACLK, 0, 0 },
41887 { "FFCID", FFCID, 0, 0 },
41888 { "IDATAATTRIB", IDATAATTRIB, 0, 0 },
41889 { "IDATASPRITE", IDATASPRITE, 0, 0 },
41890 { "IDATAFLAGS", IDATAFLAGS, 0, 0 },
41891 { "DMAPLEVELPAL", DMAPLEVELPAL, 0, 0 },
41892 { "__RESERVED_FOR_ITEMPTR", __RESERVED_FOR_ITEMPTR, 0, 0 },
41893 { "__RESERVED_FOR_NPCPTR", __RESERVED_FOR_NPCPTR, 0, 0 },
41894 { "__RESERVED_FOR_LWPNPTR", __RESERVED_FOR_LWPNPTR, 0, 0 },
41895 { "__RESERVED_FOR_EWPNPTR", __RESERVED_FOR_EWPNPTR, 0, 0 },
41896 { "SETSCREENDOOR", SETSCREENDOOR, 0, 0 },
41897 { "SETSCREENENEMY", SETSCREENENEMY, 0, 0 },
41898 { "GAMEMAXMAPS", GAMEMAXMAPS, 0, 0 },
41899 { "CREATELWPNDX", CREATELWPNDX, 0, 0 },
41900 { "__RESERVED_FOR_SCREENFLAG", __RESERVED_FOR_SCREENFLAG, 0, 0 },
41901 { "BUTTONPRESS", BUTTONPRESS, 0, 0 },
41902 { "BUTTONINPUT", BUTTONINPUT, 0, 0 },
41903 { "BUTTONHELD", BUTTONHELD, 0, 0 },
41904 { "RAWKEY", RAWKEY, 0, 0 },
41905 { "READKEY", READKEY, 0, 0 },
41906 { "JOYPADPRESS", JOYPADPRESS, 0, 0 },
41907 { "DISABLEDITEM", DISABLEDITEM, 0, 0 },
41908 { "LINKDIAG", LINKDIAG, 0, 0 },
41909 { "LINKBIGHITBOX", LINKBIGHITBOX, 0, 0 },
41910 { "LINKEATEN", LINKEATEN, 0, 0 },
41911 { "__RESERVED_FOR_LINKRETSQUARE", __RESERVED_FOR_LINKRETSQUARE, 0, 0 },
41912 { "__RESERVED_FOR_LINKWARPSOUND", __RESERVED_FOR_LINKWARPSOUND, 0, 0 },
41913 { "__RESERVED_FOR_PLAYPITWARPSFX", __RESERVED_FOR_PLAYPITWARPSFX, 0, 0 },
41914 { "__RESERVED_FOR_WARPEFFECT", __RESERVED_FOR_WARPEFFECT, 0, 0 },
41915 { "__RESERVED_FOR_PLAYWARPSOUND", __RESERVED_FOR_PLAYWARPSOUND, 0, 0 },
41916 { "LINKUSINGITEM", LINKUSINGITEM, 0, 0 },
41917 { "LINKUSINGITEMA", LINKUSINGITEMA, 0, 0 },
41918 { "LINKUSINGITEMB", LINKUSINGITEMB, 0, 0 },
41919 // { "DMAPLEVELPAL", DMAPLEVELPAL, 0, 0 },
41920 // { "LINKZHEIGHT", LINKZHEIGHT, 0, 0 },
41921 // { "ITEMINDEX", ITEMINDEX, 0, 0 },
41922 // { "LWPNINDEX", LWPNINDEX, 0, 0 },
41923 // { "EWPNINDEX", EWPNINDEX, 0, 0 },
41924 // { "NPCINDEX", NPCINDEX, 0, 0 },
41925 //TABLE END
41926 { "IDATAUSEWPN", IDATAUSEWPN, 0, 0 }, //UseWeapon
41927 { "IDATAUSEDEF", IDATAUSEDEF, 0, 0 }, //UseDefense
41928 { "IDATAWRANGE", IDATAWRANGE, 0, 0 }, //Range
41929 { "IDATAUSEMVT", IDATAUSEMVT, 0, 0 }, //Movement[]
41930 { "IDATADURATION", IDATADURATION, 0, 0 }, //Duration
41931
41932 { "IDATADUPLICATES", IDATADUPLICATES, 0, 0 }, //Duplicates
41933 { "IDATADRAWLAYER", IDATADRAWLAYER, 0, 0 }, //DrawLayer
41934 { "IDATACOLLECTFLAGS", IDATACOLLECTFLAGS, 0, 0 }, //CollectFlags
41935 { "IDATAWEAPONSCRIPT", IDATAWEAPONSCRIPT, 0, 0 }, //WeaponScript
41936 { "IDATAMISCD", IDATAMISCD, 0, 0 }, //WeaponMisc[32]
41937 { "IDATAWEAPHXOFS", IDATAWEAPHXOFS, 0, 0 }, //WeaponHitXOffset
41938 { "IDATAWEAPHYOFS", IDATAWEAPHYOFS, 0, 0 }, //WeaponHitYOffset
41939 { "IDATAWEAPHXSZ", IDATAWEAPHYSZ, 0, 0 }, //WeaponHitWidth
41940 { "IDATAWEAPHYSZ", IDATAWEAPHYSZ, 0, 0 }, //WeaponHitHeight
41941 { "IDATAWEAPHZSZ", IDATAWEAPHZSZ, 0, 0 }, //WeaponHitZHeight
41942 { "IDATAWEAPXOFS", IDATAWEAPXOFS, 0, 0 }, //WeaponDrawXOffset
41943 { "IDATAWEAPYOFS", IDATAWEAPYOFS, 0, 0 }, //WeaponDrawYOffset
41944 { "IDATAWEAPZOFS", IDATAWEAPZOFS, 0, 0 }, //WeaponDrawZOffset
41945 { "IDATAWPNINITD", IDATAWPNINITD, 0, 0 }, //WeaponD[8]
41946
41947 { "NPCWEAPSPRITE", NPCWEAPSPRITE, 0, 0 }, //WeaponSprite
41948
41949 { "DEBUGREFFFC", DEBUGREFFFC, 0, 0 }, //REFFFC
41950 { "DEBUGREFITEM", DEBUGREFITEM, 0, 0 }, //REFITEM
41951 { "DEBUGREFNPC", DEBUGREFNPC, 0, 0 }, //REFNPC
41952 { "DEBUGREFITEMDATA", DEBUGREFITEMDATA, 0, 0 }, //REFITEMCLASS
41953 { "DEBUGREFLWEAPON", DEBUGREFLWEAPON, 0, 0 }, //REFLWPN
41954 { "DEBUGREFEWEAPON", DEBUGREFEWEAPON, 0, 0 }, //REFEWPN
41955 { "DEBUGSP", DEBUGSP, 0, 0 }, //SP
41956 { "DEBUGGDR", DEBUGGDR, 0, 0 }, //GDR[256]
41957 { "SCREENWIDTH", SCREENWIDTH, 0, 0 },
41958 { "SCREENHEIGHT", SCREENHEIGHT, 0, 0 },
41959 { "SCREENVIEWX", SCREENVIEWX, 0, 0 },
41960 { "SCREENVIEWY", SCREENVIEWY, 0, 0 },
41961 { "SCREENGUY", SCREENGUY, 0, 0 },
41962 { "SCREENSTRING", SCREENSTRING, 0, 0 },
41963 { "SCREENROOM", SCREENROOM, 0, 0 },
41964 { "SCREENENTX", SCREENENTX, 0, 0 },
41965 { "SCREENENTY", SCREENENTY, 0, 0 },
41966 { "SCREENITEM", SCREENITEM, 0, 0 },
41967 { "SCREENUNDCMB", SCREENUNDCMB, 0, 0 },
41968 { "SCREENUNDCST", SCREENUNDCST, 0, 0 },
41969 { "SCREENCATCH", SCREENCATCH, 0, 0 },
41970 { "SETSCREENLAYOP", SETSCREENLAYOP, 0, 0 },
41971 { "SETSCREENSECCMB", SETSCREENSECCMB, 0, 0 },
41972 { "SETSCREENSECCST", SETSCREENSECCST, 0, 0 },
41973 { "SETSCREENSECFLG", SETSCREENSECFLG, 0, 0 },
41974 { "SETSCREENLAYMAP", SETSCREENLAYMAP, 0, 0 },
41975 { "SETSCREENLAYSCR", SETSCREENLAYSCR, 0, 0 },
41976 { "SETSCREENPATH", SETSCREENPATH, 0, 0 },
41977 { "SETSCREENWARPRX", SETSCREENWARPRX, 0, 0 },
41978 { "SETSCREENWARPRY", SETSCREENWARPRY, 0, 0 },
41979 {"GAMENUMMESSAGES", GAMENUMMESSAGES, 0, 0 },
41980 {"GAMESUBSCHEIGHT", GAMESUBSCHEIGHT, 0, 0 },
41981 {"GAMEPLAYFIELDOFS", GAMEPLAYFIELDOFS, 0, 0 },
41982 {"PASSSUBOFS", PASSSUBOFS, 0, 0 }, //
41983
41984
41985 //NPCData
41986 {"SETNPCDATASCRIPTDEF", SETNPCDATASCRIPTDEF, 0, 0 },
41987 {"SETNPCDATADEFENSE", SETNPCDATADEFENSE, 0, 0 },
41988 {"SETNPCDATASIZEFLAG", SETNPCDATASIZEFLAG, 0, 0 },
41989 {"SETNPCDATAATTRIBUTE", SETNPCDATAATTRIBUTE, 0, 0 },
41990
41991 {"SCDBLOCKWEAPON", SCDBLOCKWEAPON, 0, 0 },
41992 {"SCDSTRIKEWEAPONS", SCDSTRIKEWEAPONS, 0, 0 },
41993 {"SCDEXPANSION", SCDEXPANSION, 0, 0 },
41994 {"SETGAMEOVERELEMENT", SETGAMEOVERELEMENT, 0, 0 },
41995 {"SETGAMEOVERSTRING", SETGAMEOVERSTRING, 0, 0 },
41996 {"MOUSEARR", MOUSEARR, 0, 0 },
41997
41998 {"IDATAOVERRIDEFLWEAP", IDATAOVERRIDEFLWEAP, 0, 0 },
41999 {"IDATATILEHWEAP", IDATATILEHWEAP, 0, 0 },
42000 {"IDATATILEWWEAP", IDATATILEWWEAP, 0, 0 },
42001 {"IDATAHZSZWEAP", IDATAHZSZWEAP, 0, 0 },
42002 {"IDATAHYSZWEAP", IDATAHYSZWEAP, 0, 0 },
42003 {"IDATAHXSZWEAP", IDATAHXSZWEAP, 0, 0 },
42004 {"IDATADYOFSWEAP", IDATADYOFSWEAP, 0, 0 },
42005 {"IDATADXOFSWEAP", IDATADXOFSWEAP, 0, 0 },
42006 {"IDATAHYOFSWEAP", IDATAHYOFSWEAP, 0, 0 },
42007 {"IDATAHXOFSWEAP", IDATAHXOFSWEAP, 0, 0 },
42008 {"IDATAOVERRIDEFL", IDATAOVERRIDEFL, 0, 0 },
42009 {"IDATAPICKUP", IDATAPICKUP, 0, 0 },
42010 {"IDATATILEH", IDATATILEH, 0, 0 },
42011 {"IDATATILEW", IDATATILEW, 0, 0 },
42012 {"IDATAHZSZ", IDATAHZSZ, 0, 0 },
42013 {"IDATAHYSZ", IDATAHYSZ, 0, 0 },
42014 {"IDATAHXSZ", IDATAHXSZ, 0, 0 },
42015 {"IDATADYOFS", IDATADYOFS, 0, 0 },
42016 {"IDATADXOFS", IDATADXOFS, 0, 0 },
42017 {"IDATAHYOFS", IDATAHYOFS, 0, 0 },
42018 {"IDATAHXOFS", IDATAHXOFS, 0, 0 },
42019 //spritedata sd->
42020 {"SPRITEDATATILE", SPRITEDATATILE, 0, 0 },
42021 {"SPRITEDATAMISC", SPRITEDATAMISC, 0, 0 },
42022 {"SPRITEDATACSETS", SPRITEDATACSETS, 0, 0 },
42023 {"SPRITEDATAFRAMES", SPRITEDATAFRAMES, 0, 0 },
42024 {"SPRITEDATASPEED", SPRITEDATASPEED, 0, 0 },
42025 {"SPRITEDATATYPE", SPRITEDATATYPE, 0, 0 },
42026
42027 //npcdata nd->
42028 {"NPCDATATILE", NPCDATATILE, 0, 0 },
42029 {"NPCDATAHEIGHT", NPCDATAHEIGHT, 0, 0 },
42030 {"NPCDATAFLAGS", NPCDATAFLAGS, 0, 0 },
42031 {"NPCDATAFLAGS2", NPCDATAFLAGS2, 0, 0 },
42032 {"NPCDATAWIDTH", NPCDATAWIDTH, 0, 0 },
42033 {"NPCDATAHITSFX", NPCDATAHITSFX, 0, 0 },
42034 {"NPCDATASTILE", NPCDATASTILE, 0, 0 },
42035 {"NPCDATASWIDTH", NPCDATASWIDTH, 0, 0 },
42036 {"NPCDATASHEIGHT", NPCDATASHEIGHT, 0, 0 },
42037 {"NPCDATAETILE", NPCDATAETILE, 0, 0 },
42038 {"NPCDATAEWIDTH", NPCDATAEWIDTH, 0, 0 },
42039 {"NPCDATAEHEIGHT", NPCDATAEHEIGHT, 0, 0 },
42040 {"NPCDATAHP", NPCDATAHP, 0, 0 },
42041 {"NPCDATAFAMILY", NPCDATAFAMILY, 0, 0 },
42042 {"NPCDATACSET", NPCDATACSET, 0, 0 },
42043 {"NPCDATAANIM", NPCDATAANIM, 0, 0 },
42044 {"NPCDATAEANIM", NPCDATAEANIM, 0, 0 },
42045 {"NPCDATAFRAMERATE", NPCDATAFRAMERATE, 0, 0 },
42046 {"NPCDATAEFRAMERATE", NPCDATAEFRAMERATE, 0, 0 },
42047 {"NPCDATATOUCHDAMAGE", NPCDATATOUCHDAMAGE, 0, 0 },
42048 {"NPCDATAWEAPONDAMAGE", NPCDATAWEAPONDAMAGE, 0, 0 },
42049 {"NPCDATAWEAPON", NPCDATAWEAPON, 0, 0 },
42050 {"NPCDATARANDOM", NPCDATARANDOM, 0, 0 },
42051 {"NPCDATAHALT", NPCDATAHALT, 0, 0 },
42052 {"NPCDATASTEP", NPCDATASTEP, 0, 0 },
42053 {"NPCDATAHOMING", NPCDATAHOMING, 0, 0 },
42054 {"NPCDATAHUNGER", NPCDATAHUNGER, 0, 0 },
42055 {"NPCDATADROPSET", NPCDATADROPSET, 0, 0 },
42056 {"NPCDATABGSFX", NPCDATABGSFX, 0, 0 },
42057 {"NPCDATADEATHSFX", NPCDATADEATHSFX, 0, 0 },
42058 {"NPCDATAXOFS", NPCDATAXOFS, 0, 0 },
42059 {"NPCDATAYOFS", NPCDATAYOFS, 0, 0 },
42060 {"NPCDATAZOFS", NPCDATAZOFS, 0, 0 },
42061 {"NPCDATAHXOFS", NPCDATAHXOFS, 0, 0 },
42062 {"NPCDATAHYOFS", NPCDATAHYOFS, 0, 0 },
42063 {"NPCDATAHITWIDTH", NPCDATAHITWIDTH, 0, 0 },
42064 {"NPCDATAHITHEIGHT", NPCDATAHITHEIGHT, 0, 0 },
42065 {"NPCDATAHITZ", NPCDATAHITZ, 0, 0 },
42066 {"NPCDATATILEWIDTH", NPCDATATILEWIDTH, 0, 0 },
42067 {"NPCDATATILEHEIGHT", NPCDATATILEHEIGHT, 0, 0 },
42068 {"NPCDATAWPNSPRITE", NPCDATAWPNSPRITE, 0, 0 },
42069 {"NPCDATADEFENSE", NPCDATADEFENSE, 0, 0 },
42070 {"NPCDATASIZEFLAG", NPCDATASIZEFLAG, 0, 0 },
42071 {"NPCDATAATTRIBUTE", NPCDATAATTRIBUTE, 0, 0 },
42072
42073 {"NPCDATAFROZENTILE", NPCDATAFROZENTILE, 0, 0 },
42074 {"NPCDATAFROZENCSET", NPCDATAFROZENCSET, 0, 0 },
42075
42076 //mapdata md->
42077 {"MAPDATAVALID", MAPDATAVALID, 0, 0 },
42078 {"MAPDATAGUY", MAPDATAGUY, 0, 0 },
42079 {"MAPDATASTRING", MAPDATASTRING, 0, 0 },
42080 {"MAPDATAROOM", MAPDATAROOM, 0, 0 },
42081 {"MAPDATAITEM", MAPDATAITEM, 0, 0 },
42082 {"MAPDATAHASITEM", MAPDATAHASITEM, 0, 0 },
42083 {"MAPDATATILEWARPTYPE", MAPDATATILEWARPTYPE, 0, 0 },
42084 {"MAPDATATILEWARPOVFLAGS", MAPDATATILEWARPOVFLAGS, 0, 0 },
42085 {"MAPDATADOORCOMBOSET", MAPDATADOORCOMBOSET, 0, 0 },
42086 {"MAPDATAWARPRETX", MAPDATAWARPRETX, 0, 0 },
42087 {"MAPDATAWARPRETY", MAPDATAWARPRETY, 0, 0 },
42088 {"MAPDATAWARPRETURNC", MAPDATAWARPRETURNC, 0, 0 },
42089 {"MAPDATASTAIRX", MAPDATASTAIRX, 0, 0 },
42090 {"MAPDATASTAIRY", MAPDATASTAIRY, 0, 0 },
42091 {"MAPDATACOLOUR", MAPDATACOLOUR, 0, 0 },
42092 {"MAPDATAENEMYFLAGS", MAPDATAENEMYFLAGS, 0, 0 },
42093 {"MAPDATADOOR", MAPDATADOOR, 0, 0 },
42094 {"MAPDATATILEWARPDMAP", MAPDATATILEWARPDMAP, 0, 0 },
42095 {"MAPDATATILEWARPSCREEN", MAPDATATILEWARPSCREEN, 0, 0 },
42096 {"MAPDATAEXITDIR", MAPDATAEXITDIR, 0, 0 },
42097 {"MAPDATAENEMY", MAPDATAENEMY, 0, 0 },
42098 {"MAPDATAPATTERN", MAPDATAPATTERN, 0, 0 },
42099 {"MAPDATASIDEWARPTYPE", MAPDATASIDEWARPTYPE, 0, 0 },
42100 {"MAPDATASIDEWARPOVFLAGS", MAPDATASIDEWARPOVFLAGS, 0, 0 },
42101 {"MAPDATAWARPARRIVALX", MAPDATAWARPARRIVALX, 0, 0 },
42102 {"MAPDATAWARPARRIVALY", MAPDATAWARPARRIVALY, 0, 0 },
42103 {"MAPDATAPATH", MAPDATAPATH, 0, 0 },
42104 {"MAPDATASIDEWARPSC", MAPDATASIDEWARPSC, 0, 0 },
42105 {"MAPDATASIDEWARPDMAP", MAPDATASIDEWARPDMAP, 0, 0 },
42106 {"MAPDATASIDEWARPINDEX", MAPDATASIDEWARPINDEX, 0, 0 },
42107 {"MAPDATAUNDERCOMBO", MAPDATAUNDERCOMBO, 0, 0 },
42108 {"MAPDATAUNDERCSET", MAPDATAUNDERCSET, 0, 0 },
42109 {"MAPDATACATCHALL", MAPDATACATCHALL, 0, 0 },
42110 {"MAPDATAFLAGS", MAPDATAFLAGS, 0, 0 },
42111 {"MAPDATACSENSITIVE", MAPDATACSENSITIVE, 0, 0 },
42112 {"MAPDATANORESET", MAPDATANORESET, 0, 0 },
42113 {"MAPDATANOCARRY", MAPDATANOCARRY, 0, 0 },
42114 {"MAPDATALAYERMAP", MAPDATALAYERMAP, 0, 0 },
42115 {"MAPDATALAYERSCREEN", MAPDATALAYERSCREEN, 0, 0 },
42116 {"MAPDATALAYEROPACITY", MAPDATALAYEROPACITY, 0, 0 },
42117 {"MAPDATATIMEDWARPTICS", MAPDATATIMEDWARPTICS, 0, 0 },
42118 {"MAPDATANEXTMAP", MAPDATANEXTMAP, 0, 0 },
42119 {"MAPDATANEXTSCREEN", MAPDATANEXTSCREEN, 0, 0 },
42120 {"MAPDATASECRETCOMBO", MAPDATASECRETCOMBO, 0, 0 },
42121 {"MAPDATASECRETCSET", MAPDATASECRETCSET, 0, 0 },
42122 {"MAPDATASECRETFLAG", MAPDATASECRETFLAG, 0, 0 },
42123 {"MAPDATAVIEWX", MAPDATAVIEWX, 0, 0 },
42124 {"MAPDATAVIEWY", MAPDATAVIEWY, 0, 0 },
42125 {"MAPDATASCREENWIDTH", MAPDATASCREENWIDTH, 0, 0 },
42126 {"MAPDATASCREENHEIGHT", MAPDATASCREENHEIGHT, 0, 0 },
42127 {"MAPDATAENTRYX", MAPDATAENTRYX, 0, 0 },
42128 {"MAPDATAENTRYY", MAPDATAENTRYY, 0, 0 },
42129 {"MAPDATANUMFF", MAPDATANUMFF, 0, 0 },
42130 {"MAPDATAFFDATA", MAPDATAFFDATA, 0, 0 },
42131 {"MAPDATAFFCSET", MAPDATAFFCSET, 0, 0 },
42132 {"MAPDATAFFDELAY", MAPDATAFFDELAY, 0, 0 },
42133 {"MAPDATAFFX", MAPDATAFFX, 0, 0 },
42134 {"MAPDATAFFY", MAPDATAFFY, 0, 0 },
42135 {"MAPDATAFFXDELTA", MAPDATAFFXDELTA, 0, 0 },
42136 {"MAPDATAFFYDELTA", MAPDATAFFYDELTA, 0, 0 },
42137 {"MAPDATAFFXDELTA2", MAPDATAFFXDELTA2, 0, 0 },
42138 {"MAPDATAFFYDELTA2", MAPDATAFFYDELTA2, 0, 0 },
42139 {"MAPDATAFFFLAGS", MAPDATAFFFLAGS, 0, 0 },
42140 {"MAPDATAFFWIDTH", MAPDATAFFWIDTH, 0, 0 },
42141 {"MAPDATAFFHEIGHT", MAPDATAFFHEIGHT, 0, 0 },
42142 {"MAPDATAFFLINK", MAPDATAFFLINK, 0, 0 },
42143 {"MAPDATAFFSCRIPT", MAPDATAFFSCRIPT, 0, 0 },
42144 {"MAPDATAINTID", MAPDATAINTID, 0, 0 }, //Needs to be a function [32][10]
42145 {"MAPDATAINITA", MAPDATAINITA, 0, 0 }, //needs to be a function, [32][2]
42146 {"MAPDATAFFINITIALISED", MAPDATAFFINITIALISED, 0, 0 },
42147 {"MAPDATASCRIPTENTRY", MAPDATASCRIPTENTRY, 0, 0 },
42148 {"MAPDATASCRIPTOCCUPANCY", MAPDATASCRIPTOCCUPANCY, 0, 0 },
42149 {"MAPDATASCRIPTEXIT", MAPDATASCRIPTEXIT, 0, 0 },
42150 {"MAPDATAOCEANSFX", MAPDATAOCEANSFX, 0, 0 },
42151 {"MAPDATABOSSSFX", MAPDATABOSSSFX, 0, 0 },
42152 {"MAPDATASECRETSFX", MAPDATASECRETSFX, 0, 0 },
42153 {"MAPDATAHOLDUPSFX", MAPDATAHOLDUPSFX, 0, 0 },
42154 {"MAPDATASCREENMIDI", MAPDATASCREENMIDI, 0, 0 },
42155 {"MAPDATALENSLAYER", MAPDATALENSLAYER, 0, 0 },
42156 {"MAPDATAMISCD", MAPDATAMISCD, 0, 0},
42157
42158 {"MAPDATASCREENSTATED", MAPDATASCREENSTATED, 0, 0},
42159 {"MAPDATASCREENFLAGSD", MAPDATASCREENFLAGSD, 0, 0},
42160 {"MAPDATASCREENEFLAGSD", MAPDATASCREENEFLAGSD, 0, 0},
42161
42162
42163
42164 {"MAPDATACOMBODD", MAPDATACOMBODD, 0, 0},
42165 {"MAPDATACOMBOCD", MAPDATACOMBOCD, 0, 0},
42166 {"MAPDATACOMBOFD", MAPDATACOMBOFD, 0, 0},
42167 {"MAPDATACOMBOTD", MAPDATACOMBOTD, 0, 0},
42168 {"MAPDATACOMBOID", MAPDATACOMBOID, 0, 0},
42169 {"MAPDATACOMBOSD", MAPDATACOMBOSD, 0, 0},
42170
42171 {"SCREENDATAVALID", SCREENDATAVALID, 0, 0 },
42172 {"SCREENDATAGUY", SCREENDATAGUY, 0, 0 },
42173 {"SCREENDATASTRING", SCREENDATASTRING, 0, 0 },
42174 {"SCREENDATAROOM", SCREENDATAROOM, 0, 0 },
42175 {"SCREENDATAITEM", SCREENDATAITEM, 0, 0 },
42176 {"SCREENDATAHASITEM", SCREENDATAHASITEM, 0, 0 },
42177 {"SCREENDATATILEWARPTYPE", SCREENDATATILEWARPTYPE, 0, 0 },
42178 {"SCREENDATATILEWARPOVFLAGS", SCREENDATATILEWARPOVFLAGS, 0, 0 },
42179 {"SCREENDATADOORCOMBOSET", SCREENDATADOORCOMBOSET, 0, 0 },
42180 {"SCREENDATAWARPRETX", SCREENDATAWARPRETX, 0, 0 },
42181 {"SCREENDATAWARPRETY", SCREENDATAWARPRETY, 0, 0 },
42182 {"SCREENDATAWARPRETURNC", SCREENDATAWARPRETURNC, 0, 0 },
42183 {"SCREENDATASTAIRX", SCREENDATASTAIRX, 0, 0 },
42184 {"SCREENDATASTAIRY", SCREENDATASTAIRY, 0, 0 },
42185 {"SCREENDATACOLOUR", SCREENDATACOLOUR, 0, 0 },
42186 {"SCREENDATAENEMYFLAGS", SCREENDATAENEMYFLAGS, 0, 0 },
42187 {"SCREENDATADOOR", SCREENDATADOOR, 0, 0 },
42188 {"SCREENDATATILEWARPDMAP", SCREENDATATILEWARPDMAP, 0, 0 },
42189 {"SCREENDATATILEWARPSCREEN", SCREENDATATILEWARPSCREEN, 0, 0 },
42190 {"SCREENDATAEXITDIR", SCREENDATAEXITDIR, 0, 0 },
42191 {"SCREENDATAENEMY", SCREENDATAENEMY, 0, 0 },
42192 {"SCREENDATAPATTERN", SCREENDATAPATTERN, 0, 0 },
42193 {"SCREENDATASIDEWARPTYPE", SCREENDATASIDEWARPTYPE, 0, 0 },
42194 {"SCREENDATASIDEWARPOVFLAGS", SCREENDATASIDEWARPOVFLAGS, 0, 0 },
42195 {"SCREENDATAWARPARRIVALX", SCREENDATAWARPARRIVALX, 0, 0 },
42196 {"SCREENDATAWARPARRIVALY", SCREENDATAWARPARRIVALY, 0, 0 },
42197 {"SCREENDATAPATH", SCREENDATAPATH, 0, 0 },
42198 {"SCREENDATASIDEWARPSC", SCREENDATASIDEWARPSC, 0, 0 },
42199 {"SCREENDATASIDEWARPDMAP", SCREENDATASIDEWARPDMAP, 0, 0 },
42200 {"SCREENDATASIDEWARPINDEX", SCREENDATASIDEWARPINDEX, 0, 0 },
42201 {"SCREENDATAUNDERCOMBO", SCREENDATAUNDERCOMBO, 0, 0 },
42202 {"SCREENDATAUNDERCSET", SCREENDATAUNDERCSET, 0, 0 },
42203 {"SCREENDATACATCHALL", SCREENDATACATCHALL, 0, 0 },
42204 {"SCREENDATAFLAGS", SCREENDATAFLAGS, 0, 0 },
42205 {"SCREENDATACSENSITIVE", SCREENDATACSENSITIVE, 0, 0 },
42206 {"SCREENDATANORESET", SCREENDATANORESET, 0, 0 },
42207 {"SCREENDATANOCARRY", SCREENDATANOCARRY, 0, 0 },
42208 {"SCREENDATALAYERMAP", SCREENDATALAYERMAP, 0, 0 },
42209 {"SCREENDATALAYERSCREEN", SCREENDATALAYERSCREEN, 0, 0 },
42210 {"SCREENDATALAYEROPACITY", SCREENDATALAYEROPACITY, 0, 0 },
42211 {"SCREENDATATIMEDWARPTICS", SCREENDATATIMEDWARPTICS, 0, 0 },
42212 {"SCREENDATANEXTMAP", SCREENDATANEXTMAP, 0, 0 },
42213 {"SCREENDATANEXTSCREEN", SCREENDATANEXTSCREEN, 0, 0 },
42214 {"SCREENDATASECRETCOMBO", SCREENDATASECRETCOMBO, 0, 0 },
42215 {"SCREENDATASECRETCSET", SCREENDATASECRETCSET, 0, 0 },
42216 {"SCREENDATASECRETFLAG", SCREENDATASECRETFLAG, 0, 0 },
42217 {"SCREENDATAVIEWX", SCREENDATAVIEWX, 0, 0 },
42218 {"SCREENDATAVIEWY", SCREENDATAVIEWY, 0, 0 },
42219 {"SCREENDATASCREENWIDTH", SCREENDATASCREENWIDTH, 0, 0 },
42220 {"SCREENDATASCREENHEIGHT", SCREENDATASCREENHEIGHT, 0, 0 },
42221 {"SCREENDATAENTRYX", SCREENDATAENTRYX, 0, 0 },
42222 {"SCREENDATAENTRYY", SCREENDATAENTRYY, 0, 0 },
42223 {"SCREENDATANUMFF", SCREENDATANUMFF, 0, 0 },
42224 {"SCREENDATAFFDATA", SCREENDATAFFDATA, 0, 0 },
42225 {"SCREENDATAFFCSET", SCREENDATAFFCSET, 0, 0 },
42226 {"SCREENDATAFFDELAY", SCREENDATAFFDELAY, 0, 0 },
42227 {"SCREENDATAFFX", SCREENDATAFFX, 0, 0 },
42228 {"SCREENDATAFFY", SCREENDATAFFY, 0, 0 },
42229 {"SCREENDATAFFXDELTA", SCREENDATAFFXDELTA, 0, 0 },
42230 {"SCREENDATAFFYDELTA", SCREENDATAFFYDELTA, 0, 0 },
42231 {"SCREENDATAFFXDELTA2", SCREENDATAFFXDELTA2, 0, 0 },
42232 {"SCREENDATAFFYDELTA2", SCREENDATAFFYDELTA2, 0, 0 },
42233 {"SCREENDATAFFFLAGS", SCREENDATAFFFLAGS, 0, 0 },
42234 {"SCREENDATAFFWIDTH", SCREENDATAFFWIDTH, 0, 0 },
42235 {"SCREENDATAFFHEIGHT", SCREENDATAFFHEIGHT, 0, 0 },
42236 {"SCREENDATAFFLINK", SCREENDATAFFLINK, 0, 0 },
42237 {"SCREENDATAFFSCRIPT", SCREENDATAFFSCRIPT, 0, 0 },
42238 {"SCREENDATAINTID", SCREENDATAINTID, 0, 0 }, //Needs to be a function [32][10]
42239 {"SCREENDATAINITA", SCREENDATAINITA, 0, 0 }, //needs to be a function, [32][2]
42240 {"SCREENDATAFFINITIALISED", SCREENDATAFFINITIALISED, 0, 0 },
42241 {"SCREENDATASCRIPTENTRY", SCREENDATASCRIPTENTRY, 0, 0 },
42242 {"SCREENDATASCRIPTOCCUPANCY", SCREENDATASCRIPTOCCUPANCY, 0, 0 },
42243 {"SCREENDATASCRIPTEXIT", SCREENDATASCRIPTEXIT, 0, 0 },
42244 {"SCREENDATAOCEANSFX", SCREENDATAOCEANSFX, 0, 0 },
42245 {"SCREENDATABOSSSFX", SCREENDATABOSSSFX, 0, 0 },
42246 {"SCREENDATASECRETSFX", SCREENDATASECRETSFX, 0, 0 },
42247 {"SCREENDATAHOLDUPSFX", SCREENDATAHOLDUPSFX, 0, 0 },
42248 {"SCREENDATASCREENMIDI", SCREENDATASCREENMIDI, 0, 0 },
42249 {"SCREENDATALENSLAYER", SCREENDATALENSLAYER, 0, 0 },
42250
42251 {"LINKSCRIPTTILE", LINKSCRIPTTILE, 0, 0 },
42252 {"LINKSCRIPFLIP", LINKSCRIPFLIP, 0, 0 },
42253 {"MAPDATAITEMX", MAPDATAITEMX, 0, 0 },
42254 {"MAPDATAITEMY", MAPDATAITEMY, 0, 0 },
42255 {"SCREENDATAITEMX", SCREENDATAITEMX, 0, 0 },
42256 {"SCREENDATAITEMY", SCREENDATAITEMY, 0, 0 },
42257
42258 {"MAPDATAFFEFFECTWIDTH", MAPDATAFFEFFECTWIDTH, 0, 0 },
42259 {"MAPDATAFFEFFECTHEIGHT", MAPDATAFFEFFECTHEIGHT, 0, 0 },
42260 {"SCREENDATAFFEFFECTWIDTH", SCREENDATAFFEFFECTWIDTH, 0, 0 },
42261 {"SCREENDATAFFEFFECTHEIGHT", SCREENDATAFFEFFECTHEIGHT, 0, 0 },
42262
42263 {"LOADMAPDATA", LOADMAPDATA, 0, 0 },
42264 {"LWPNPARENT", LWPNPARENT, 0, 0 },
42265 {"LWPNLEVEL", LWPNLEVEL, 0, 0 },
42266 {"EWPNLEVEL", EWPNLEVEL, 0, 0 },
42267 {"EWPNPARENT", EWPNPARENT, 0, 0 },
42268
42269
42270 {"SHOPDATANAME", SHOPDATANAME, 0, 0 },
42271 {"SHOPDATAITEM", SHOPDATAITEM, 0, 0 },
42272 {"SHOPDATAHASITEM", SHOPDATAHASITEM, 0, 0 },
42273 {"SHOPDATAPRICE", SHOPDATAPRICE, 0, 0 },
42274 {"SHOPDATASTRING", SHOPDATASTRING, 0, 0 },
42275
42276 {"NPCDATASHIELD", NPCDATASHIELD, 0, 0 },
42277 {"NPCSHIELD", NPCSHIELD, 0, 0 },
42278 {"AUDIOVOLUME", AUDIOVOLUME, 0, 0 },
42279 {"AUDIOPAN", AUDIOPAN, 0, 0 },
42280
42281 {"MESSAGEDATANEXT", MESSAGEDATANEXT, 0, 0 },
42282 {"MESSAGEDATATILE", MESSAGEDATATILE, 0, 0 },
42283 {"MESSAGEDATACSET", MESSAGEDATACSET, 0, 0 },
42284 {"MESSAGEDATATRANS", MESSAGEDATATRANS, 0, 0 },
42285 {"MESSAGEDATAFONT", MESSAGEDATAFONT, 0, 0 },
42286 {"MESSAGEDATAX", MESSAGEDATAX, 0, 0 },
42287 {"MESSAGEDATAY", MESSAGEDATAY, 0, 0 },
42288 {"MESSAGEDATAW", MESSAGEDATAW, 0, 0 },
42289 {"MESSAGEDATAH", MESSAGEDATAH, 0, 0 },
42290 {"MESSAGEDATASFX", MESSAGEDATASFX, 0, 0 },
42291 {"MESSAGEDATALISTPOS", MESSAGEDATALISTPOS, 0, 0 },
42292 {"MESSAGEDATAVSPACE", MESSAGEDATAVSPACE, 0, 0 },
42293 {"MESSAGEDATAHSPACE", MESSAGEDATAHSPACE, 0, 0 },
42294 {"MESSAGEDATAFLAGS", MESSAGEDATAFLAGS, 0, 0 },
42295
42296 {"DMAPDATAMAP", DMAPDATAMAP, 0, 0 },
42297 {"DMAPDATALEVEL", DMAPDATALEVEL, 0, 0 },
42298 {"DMAPDATAOFFSET", DMAPDATAOFFSET, 0, 0 },
42299 {"DMAPDATACOMPASS", DMAPDATACOMPASS, 0, 0 },
42300 {"DMAPDATAPALETTE", DMAPDATAPALETTE, 0, 0 },
42301 {"DMAPDATAMIDI", DMAPDATAMIDI, 0, 0 },
42302 {"DMAPDATACONTINUE", DMAPDATACONTINUE, 0, 0 },
42303 {"DMAPDATATYPE", DMAPDATATYPE, 0, 0 },
42304 {"DMAPDATAGRID", DMAPDATAGRID, 0, 0 },
42305 {"DMAPDATAMINIMAPTILE", DMAPDATAMINIMAPTILE, 0, 0 },
42306 {"DMAPDATAMINIMAPCSET", DMAPDATAMINIMAPCSET, 0, 0 },
42307 {"DMAPDATALARGEMAPTILE", DMAPDATALARGEMAPTILE, 0, 0 },
42308 {"DMAPDATALARGEMAPCSET", DMAPDATALARGEMAPCSET, 0, 0 },
42309 {"DMAPDATAMUISCTRACK", DMAPDATAMUISCTRACK, 0, 0 },
42310 {"DMAPDATASUBSCRA", DMAPDATASUBSCRA, 0, 0 },
42311 {"DMAPDATASUBSCRP", DMAPDATASUBSCRP, 0, 0 },
42312 {"DMAPDATADISABLEDITEMS", DMAPDATADISABLEDITEMS, 0, 0 },
42313 {"DMAPDATAFLAGS", DMAPDATAFLAGS, 0, 0 },
42314
42315 {"NPCFROZEN", NPCFROZEN, 0, 0 },
42316 {"NPCFROZENTILE", NPCFROZENTILE, 0, 0 },
42317 {"NPCFROZENCSET", NPCFROZENCSET, 0, 0 },
42318
42319 {"ITEMPSTRING", ITEMPSTRING, 0, 0 },
42320 {"ITEMPSTRINGFLAGS", ITEMPSTRINGFLAGS, 0, 0 },
42321 {"ITEMOVERRIDEFLAGS", ITEMOVERRIDEFLAGS, 0, 0 },
42322 {"LINKPUSH", LINKPUSH, 0, 0 },
42323 {"LINKSTUN", LINKSTUN, 0, 0 },
42324 {"IDATACOSTCOUNTER", IDATACOSTCOUNTER, 0, 0 },
42325 {"TYPINGMODE", TYPINGMODE, 0, 0 },
42326 // {"DMAPDATAGRAVITY", DMAPDATAGRAVITY, 0, 0 },
42327 // {"DMAPDATAJUMPLAYER", DMAPDATAJUMPLAYER, 0, 0 },
42328 //end ffscript vars
42329 //END VARS END OF BYTECODE
42330
42331 //newcombo
42332 {"COMBODTILE", COMBODTILE, 0, 0 },
42333 {"COMBODFLIP", COMBODFLIP, 0, 0 },
42334 {"COMBODWALK", COMBODWALK, 0, 0 },
42335 {"COMBODTYPE", COMBODTYPE, 0, 0 },
42336 {"COMBODCSET", COMBODCSET, 0, 0 },
42337 {"COMBODFOO", COMBODFOO, 0, 0 },
42338 {"COMBODFRAMES", COMBODFRAMES, 0, 0 },
42339 {"COMBODNEXTD", COMBODNEXTD, 0, 0 },
42340 {"COMBODNEXTC", COMBODNEXTC, 0, 0 },
42341 {"COMBODFLAG", COMBODFLAG, 0, 0 },
42342 {"COMBODSKIPANIM", COMBODSKIPANIM, 0, 0 },
42343 {"COMBODNEXTTIMER", COMBODNEXTTIMER, 0, 0 },
42344 {"COMBODAKIMANIMY", COMBODAKIMANIMY, 0, 0 },
42345 {"COMBODANIMFLAGS", COMBODANIMFLAGS, 0, 0 },
42346 {"COMBODEXPANSION", COMBODEXPANSION, 0, 0 },
42347 {"COMBODATTRIBUTES", COMBODATTRIBUTES, 0, 0 },
42348 {"COMBODATTRIBYTES", COMBODATTRIBYTES, 0, 0 },
42349 {"COMBODUSRFLAGS", COMBODUSRFLAGS, 0, 0 },
42350 {"COMBODTRIGGERFLAGS", COMBODTRIGGERFLAGS, 0, 0 },
42351 {"COMBODTRIGGERLEVEL", COMBODTRIGGERLEVEL, 0, 0 },
42352
42353 //comboclass
42354 {"COMBODNAME", COMBODNAME, 0, 0 },
42355 {"COMBODBLOCKNPC", COMBODBLOCKNPC, 0, 0 },
42356 {"COMBODBLOCKHOLE", COMBODBLOCKHOLE, 0, 0 },
42357 {"COMBODBLOCKTRIG", COMBODBLOCKTRIG, 0, 0 },
42358 {"COMBODBLOCKWEAPON", COMBODBLOCKWEAPON, 0, 0 },
42359 {"COMBODCONVXSPEED", COMBODCONVXSPEED, 0, 0 },
42360 {"COMBODCONVYSPEED", COMBODCONVYSPEED, 0, 0 },
42361 {"COMBODSPAWNNPC", COMBODSPAWNNPC, 0, 0 },
42362 {"COMBODSPAWNNPCWHEN", COMBODSPAWNNPCWHEN, 0, 0 },
42363 {"COMBODSPAWNNPCCHANGE", COMBODSPAWNNPCCHANGE, 0, 0 },
42364 {"COMBODDIRCHANGETYPE", COMBODDIRCHANGETYPE, 0, 0 },
42365 {"COMBODDISTANCECHANGETILES", COMBODDISTANCECHANGETILES, 0, 0 },
42366 {"COMBODDIVEITEM", COMBODDIVEITEM, 0, 0 },
42367 {"COMBODDOCK", COMBODDOCK, 0, 0 },
42368 {"COMBODFAIRY", COMBODFAIRY, 0, 0 },
42369 {"COMBODFFATTRCHANGE", COMBODFFATTRCHANGE, 0, 0 },
42370 {"COMBODFOORDECOTILE", COMBODFOORDECOTILE, 0, 0 },
42371 {"COMBODFOORDECOTYPE", COMBODFOORDECOTYPE, 0, 0 },
42372 {"COMBODHOOKSHOTPOINT", COMBODHOOKSHOTPOINT, 0, 0 },
42373 {"COMBODLADDERPASS", COMBODLADDERPASS, 0, 0 },
42374 {"COMBODLOCKBLOCK", COMBODLOCKBLOCK, 0, 0 },
42375 {"COMBODLOCKBLOCKCHANGE", COMBODLOCKBLOCKCHANGE, 0, 0 },
42376 {"COMBODMAGICMIRROR", COMBODMAGICMIRROR, 0, 0 },
42377 {"COMBODMODHPAMOUNT", COMBODMODHPAMOUNT, 0, 0 },
42378 {"COMBODMODHPDELAY", COMBODMODHPDELAY, 0, 0 },
42379 {"COMBODMODHPTYPE", COMBODMODHPTYPE, 0, 0 },
42380 {"COMBODNMODMPAMOUNT", COMBODNMODMPAMOUNT, 0, 0 },
42381 {"COMBODMODMPDELAY", COMBODMODMPDELAY, 0, 0 },
42382 {"COMBODMODMPTYPE", COMBODMODMPTYPE, 0, 0 },
42383 {"COMBODNOPUSHBLOCK", COMBODNOPUSHBLOCK, 0, 0 },
42384 {"COMBODOVERHEAD", COMBODOVERHEAD, 0, 0 },
42385 {"COMBODPLACENPC", COMBODPLACENPC, 0, 0 },
42386 {"COMBODPUSHDIR", COMBODPUSHDIR, 0, 0 },
42387 {"COMBODPUSHWAIT", COMBODPUSHWAIT, 0, 0 },
42388 {"COMBODPUSHHEAVY", COMBODPUSHHEAVY, 0, 0 },
42389 {"COMBODPUSHED", COMBODPUSHED, 0, 0 },
42390 {"COMBODRAFT", COMBODRAFT, 0, 0 },
42391 {"COMBODRESETROOM", COMBODRESETROOM, 0, 0 },
42392 {"COMBODSAVEPOINTTYPE", COMBODSAVEPOINTTYPE, 0, 0 },
42393 {"COMBODSCREENFREEZETYPE", COMBODSCREENFREEZETYPE, 0, 0 },
42394 {"COMBODSECRETCOMBO", COMBODSECRETCOMBO, 0, 0 },
42395 {"COMBODSINGULAR", COMBODSINGULAR, 0, 0 },
42396 {"COMBODSLOWWALK", COMBODSLOWWALK, 0, 0 },
42397 {"COMBODSTATUETYPEs", COMBODSTATUETYPE, 0, 0 },
42398 {"COMBODSTEPTYPE", COMBODSTEPTYPE, 0, 0 },
42399 {"COMBODSTEPCHANGEINTO", COMBODSTEPCHANGEINTO, 0, 0 },
42400 {"COMBODSTRIKEWEAPONS", COMBODSTRIKEWEAPONS, 0, 0 },
42401 {"COMBODSTRIKEREMNANTS", COMBODSTRIKEREMNANTS, 0, 0 },
42402 {"COMBODSTRIKEREMNANTSTYPE", COMBODSTRIKEREMNANTSTYPE, 0, 0 },
42403 {"COMBODSTRIKECHANGE", COMBODSTRIKECHANGE, 0, 0 },
42404 {"COMBODSTRIKEITEM", COMBODSTRIKEITEM, 0, 0 },
42405 {"COMBODTOUCHITEM", COMBODTOUCHITEM, 0, 0 },
42406 {"COMBODTOUCHSTAIRS", COMBODTOUCHSTAIRS, 0, 0 },
42407 {"COMBODTRIGGERTYPE", COMBODTRIGGERTYPE, 0, 0 },
42408 {"COMBODTRIGGERSENS", COMBODTRIGGERSENS, 0, 0 },
42409 {"COMBODWARPTYPE", COMBODWARPTYPE, 0, 0 },
42410 {"COMBODWARPSENS", COMBODWARPSENS, 0, 0 },
42411 {"COMBODWARPDIRECT", COMBODWARPDIRECT, 0, 0 },
42412 {"COMBODWARPLOCATION", COMBODWARPLOCATION, 0, 0 },
42413 {"COMBODWATER", COMBODWATER, 0, 0 },
42414 {"COMBODWHISTLE", COMBODWHISTLE, 0, 0 },
42415 {"COMBODWINGAME", COMBODWINGAME, 0, 0 },
42416 {"COMBODBLOCKWPNLEVEL", COMBODBLOCKWPNLEVEL, 0, 0 },
42417
42418 {"TYPINGMODE", TYPINGMODE, 0, 0 },
42419 {"TYPINGMODE", TYPINGMODE, 0, 0 },
42420 {"LINKHITBY", LINKHITBY, 0, 0 },
42421 {"LINKDEFENCE", LINKDEFENCE, 0, 0 },
42422 {"NPCHITBY", NPCHITBY, 0, 0 },
42423 {"NPCISCORE", NPCISCORE, 0, 0 },
42424 {"NPCSCRIPTUID", NPCSCRIPTUID, 0, 0 },
42425 {"LWEAPONSCRIPTUID", LWEAPONSCRIPTUID, 0, 0 },
42426 {"EWEAPONSCRIPTUID", EWEAPONSCRIPTUID, 0, 0 },
42427 {"ITEMSCRIPTUID", ITEMSCRIPTUID, 0, 0 },
42428
42429 {"DMAPDATASIDEVIEW", DMAPDATASIDEVIEW, 0, 0 },
42430
42431 {"DONULL", DONULL, 0, 0 },
42432 {"DEBUGD", DEBUGD, 0, 0 },
42433 {"GETPIXEL", GETPIXEL, 0, 0 },
42434 {"DOUNTYPE", DOUNTYPE, 0, 0 },
42435 {"NPCBEHAVIOUR", NPCBEHAVIOUR, 0, 0 },
42436 {"NPCDATABEHAVIOUR", NPCDATABEHAVIOUR, 0, 0 },
42437 {"CREATEBITMAP", CREATEBITMAP, 0, 0 },
42438 {"LINKTILEMOD", LINKTILEMOD, 0, 0 },
42439 {"NPCINITD", NPCINITD, 0, 0 },
42440 {"NPCCOLLISION", NPCCOLLISION, 0, 0 },
42441 {"NPCLINEDUP", NPCLINEDUP, 0, 0 },
42442
42443 {"NPCDATAINITD", NPCLINEDUP, 0, 0 },
42444 {"NPCDATASCRIPT", NPCDATASCRIPT, 0, 0 },
42445 {"NPCMATCHINITDLABEL", NPCMATCHINITDLABEL, 0, 0 },
42446 //lweapon scripts
42447 {"LWPNSCRIPT", LWPNSCRIPT, 0, 0 },
42448 {"LWPNINITD", LWPNINITD, 0, 0 },
42449 {"ITEMFAMILY", ITEMFAMILY, 0, 0 },
42450 {"ITEMLEVEL", ITEMLEVEL, 0, 0 },
42451
42452 {"EWPNSCRIPT", EWPNSCRIPT, 0, 0 },
42453 {"EWPNINITD", EWPNINITD, 0, 0 },
42454
42455 {"NPCSCRIPT", NPCSCRIPT, 0, 0 },
42456
42457 {"DMAPSCRIPT", DMAPSCRIPT, 0, 0 },
42458 {"DMAPINITD", DMAPINITD, 0, 0 },
42459
42460 {"SCREENSCRIPT", SCREENSCRIPT, 0, 0 },
42461 {"SCREENINITD", SCREENINITD, 0, 0 },
42462
42463 {"LINKINITD", LINKINITD, 0, 0 },
42464 {"NPCDATAWEAPONINITD", NPCDATAWEAPONINITD, 0, 0 },
42465 {"NPCDATAWEAPONSCRIPT", NPCDATAWEAPONSCRIPT, 0, 0 },
42466
42467 {"NPCSCRIPTTILE", NPCSCRIPTTILE, 0, 0 },
42468 {"NPCSCRIPTFLIP", NPCSCRIPTFLIP, 0, 0 },
42469 {"LWPNSCRIPTTILE", LWPNSCRIPTTILE, 0, 0 },
42470 {"LWPNSCRIPTFLIP", LWPNSCRIPTFLIP, 0, 0 },
42471 {"EWPNSCRIPTTILE", EWPNSCRIPTTILE, 0, 0 },
42472 {"EWPNSCRIPTFLIP", EWPNSCRIPTFLIP, 0, 0 },
42473
42474 {"LINKENGINEANIMATE", LINKENGINEANIMATE, 0, 0 },
42475 {"NPCENGINEANIMATE", NPCENGINEANIMATE, 0, 0 },
42476 {"LWPNENGINEANIMATE", LWPNENGINEANIMATE, 0, 0 },
42477 {"EWPNENGINEANIMATE", EWPNENGINEANIMATE, 0, 0 },
42478 {"SKIPCREDITS", SKIPCREDITS, 0, 0 },
42479 {"SKIPF6", SKIPF6, 0, 0 },
42480 {"LWPNUSEWEAPON", LWPNUSEWEAPON, 0, 0 },
42481 {"LWPNUSEDEFENCE", LWPNUSEDEFENCE, 0, 0 },
42482 {"LWPNROTATION", LWPNROTATION, 0, 0 },
42483 {"EWPNROTATION", EWPNROTATION, 0, 0 },
42484 {"NPCROTATION", NPCROTATION, 0, 0 },
42485 {"ITEMROTATION", ITEMROTATION, 0, 0 },
42486 {"LINKROTATION", LINKROTATION, 0, 0 },
42487 {"LWPNSCALE", LWPNSCALE, 0, 0 },
42488 {"EWPNSCALE", EWPNSCALE, 0, 0 },
42489 {"NPCSCALE", NPCSCALE, 0, 0 },
42490 {"ITEMSCALE", ITEMSCALE, 0, 0 },
42491 {"LINKSCALE", LINKSCALE, 0, 0 },
42492 {"ITEMSPRITESCRIPT", ITEMSPRITESCRIPT, 0, 0 },
42493 {"FFRULE", FFRULE, 0, 0 },
42494 {"NUMDRAWS", NUMDRAWS, 0, 0 },
42495 {"MAXDRAWS", MAXDRAWS, 0, 0 },
42496 {"BITMAPWIDTH", BITMAPWIDTH, 0, 0 },
42497 {"BITMAPHEIGHT", BITMAPHEIGHT, 0, 0 },
42498 {"ALLOCATEBITMAPR", ALLOCATEBITMAPR, 0, 0 },
42499 {"KEYMODIFIERS", KEYMODIFIERS, 0, 0 },
42500 {"SIMULATEKEYPRESS", SIMULATEKEYPRESS, 0, 0 },
42501 {"KEYBINDINGS", KEYBINDINGS, 0, 0 },
42502
42503 {"SCREENSCRIPT", SCREENSCRIPT, 0, 0 },
42504 {"SCREENINITD", SCREENINITD, 0, 0 },
42505 {"MAPDATASCRIPT", MAPDATASCRIPT, 0, 0 },
42506 {"MAPDATAINITDARRAY", MAPDATAINITDARRAY, 0, 0 },
42507 {"LWPNGRAVITY", LWPNGRAVITY, 0, 0 },
42508 {"EWPNGRAVITY", EWPNGRAVITY, 0, 0 },
42509 {"NPCGRAVITY", NPCGRAVITY, 0, 0 },
42510 {"ITEMGRAVITY", ITEMGRAVITY, 0, 0 },
42511
42512 {"MAPDATASIDEWARPID", MAPDATASIDEWARPID, 0, 0 },
42513 {"SCREENSIDEWARPID", SCREENSIDEWARPID, 0, 0 },
42514 {"SCREENDATALAYERINVIS", SCREENDATALAYERINVIS, 0, 0 },
42515 {"SCREENDATASCRIPTDRAWS", SCREENDATASCRIPTDRAWS, 0, 0 },
42516 {"MAPDATALAYERINVIS", MAPDATALAYERINVIS, 0, 0 },
42517 {"MAPDATASCRIPTDRAWS", MAPDATASCRIPTDRAWS, 0, 0 },
42518
42519 {"ITEMSCRIPTTILE", ITEMSCRIPTTILE, 0, 0 },
42520 {"ITEMSCRIPTFLIP", ITEMSCRIPTFLIP, 0, 0 },
42521 {"MAPDATAMAP", MAPDATAMAP, 0, 0 },
42522 {"MAPDATASCREEN", MAPDATASCREEN, 0, 0 },
42523 {"IDATAVALIDATE", IDATAVALIDATE, 0, 0 },
42524 { "DISABLEKEY", DISABLEKEY, 0, 0 },
42525 { "DISABLEBUTTON", DISABLEBUTTON, 0, 0 },
42526 { "GAMESUSPEND", GAMESUSPEND, 0, 0 },
42527 { "LINKOTILE", LINKOTILE, 0, 0 },
42528 { "LINKOFLIP", LINKOFLIP, 0, 0 },
42529 { "ITEMSPRITEINITD", ITEMSPRITEINITD, 0, 0 },
42530
42531 { "ZSCRIPTVERSION", ZSCRIPTVERSION, 0, 0 },
42532 { "REFFILE", REFFILE, 0, 0 },
42533 { "LINKCLIMBING", LINKCLIMBING, 0, 0 },
42534 { "NPCIMMORTAL", NPCIMMORTAL, 0, 0 },
42535 { "NPCNOSLIDE", NPCNOSLIDE, 0, 0 },
42536 { "NPCKNOCKBACKSPEED", NPCKNOCKBACKSPEED, 0, 0 },
42537 { "NPCNOSCRIPTKB", NPCNOSCRIPTKB, 0, 0 },
42538 { "GETRENDERTARGET", GETRENDERTARGET, 0, 0 },
42539 { "HERONOSTEPFORWARD", HERONOSTEPFORWARD, 0, 0 },
42540 { "SCREENDATATWARPRETSQR", SCREENDATATWARPRETSQR, 0, 0 },
42541 { "SCREENDATASWARPRETSQR", SCREENDATASWARPRETSQR, 0, 0 },
42542 { "MAPDATATWARPRETSQR", MAPDATATWARPRETSQR, 0, 0 },
42543 { "MAPDATASWARPRETSQR", MAPDATASWARPRETSQR, 0, 0 },
42544 { "NPCSUBMERGED", NPCSUBMERGED, 0, 0 },
42545 { "GAMEGRAVITY", GAMEGRAVITY, 0, 0 },
42546 { "COMBODASPEED", COMBODASPEED, 0, 0 },
42547 { "DROPSETITEMS", DROPSETITEMS, 0, 0 },
42548 { "DROPSETCHANCES", DROPSETCHANCES, 0, 0 },
42549 { "DROPSETNULLCHANCE", DROPSETNULLCHANCE, 0, 0 },
42550 { "DROPSETCHOOSE", DROPSETCHOOSE, 0, 0 },
42551 { "NPCPARENTUID", NPCPARENTUID, 0, 0 },
42552 { "KEYPRESS", KEYPRESS, 0, 0 },
42553 { "KEYINPUT", KEYINPUT, 0, 0 },
42554 { "SPRITEMAXNPC", SPRITEMAXNPC, 0, 0 },
42555 { "SPRITEMAXLWPN", SPRITEMAXLWPN, 0, 0 },
42556 { "SPRITEMAXEWPN", SPRITEMAXEWPN, 0, 0 },
42557 { "SPRITEMAXITEM", SPRITEMAXITEM, 0, 0 },
42558 { "SPRITEMAXPARTICLE", SPRITEMAXPARTICLE, 0, 0 },
42559 { "SPRITEMAXDECO", SPRITEMAXDECO, 0, 0 },
42560 { "HEROHEALTHBEEP", HEROHEALTHBEEP, 0, 0 },
42561 { "NPCRANDOM", NPCRANDOM, 0, 0 },
42562 { "COMBOXR", COMBOXR, 0, 0 },
42563 { "COMBOYR", COMBOYR, 0, 0 },
42564 { "COMBOPOSR", COMBOPOSR, 0, 0 },
42565 { "COMBODATASCRIPT", COMBODATASCRIPT, 0, 0 },
42566 { "COMBODATAINITD", COMBODATAINITD, 0, 0 },
42567 { "HEROSCRIPTCSET", HEROSCRIPTCSET, 0, 0 },
42568 { "SHOPDATATYPE", SHOPDATATYPE, 0, 0 },
42569 { "HEROSTEPS", HEROSTEPS, 0, 0 },
42570 { "HEROSTEPRATE", HEROSTEPRATE, 0, 0 },
42571 { "COMBODOTILE", COMBODOTILE, 0, 0 },
42572 { "COMBODFRAME", COMBODFRAME, 0, 0 },
42573 { "COMBODACLK", COMBODACLK, 0, 0 },
42574 { "PC", PC, 0, 0 },
42575 { "GAMESCROLLING", GAMESCROLLING, 0, 0 },
42576 { "MESSAGEDATAMARGINS", MESSAGEDATAMARGINS, 0, 0 },
42577 { "MESSAGEDATAPORTTILE", MESSAGEDATAPORTTILE, 0, 0 },
42578 { "MESSAGEDATAPORTCSET", MESSAGEDATAPORTCSET, 0, 0 },
42579 { "MESSAGEDATAPORTX", MESSAGEDATAPORTX, 0, 0 },
42580 { "MESSAGEDATAPORTY", MESSAGEDATAPORTY, 0, 0 },
42581 { "MESSAGEDATAPORTWID", MESSAGEDATAPORTWID, 0, 0 },
42582 { "MESSAGEDATAPORTHEI", MESSAGEDATAPORTHEI, 0, 0 },
42583 { "MESSAGEDATAFLAGSARR", MESSAGEDATAFLAGSARR, 0, 0 },
42584 { "FILEPOS", FILEPOS, 0, 0 },
42585 { "FILEEOF", FILEEOF, 0, 0 },
42586 { "FILEERR", FILEERR, 0, 0 },
42587 { "MESSAGEDATATEXTWID", MESSAGEDATATEXTWID, 0, 0 },
42588 { "MESSAGEDATATEXTHEI", MESSAGEDATATEXTHEI, 0, 0 },
42589 { "SWITCHKEY", SWITCHKEY, 0, 0 },
42590 { "INCQST", INCQST, 0, 0 },
42591 { "HEROJUMPCOUNT", HEROJUMPCOUNT, 0, 0 },
42592 { "HEROPULLDIR", HEROPULLDIR, 0, 0 },
42593 { "HEROPULLCLK", HEROPULLCLK, 0, 0 },
42594 { "HEROFALLCLK", HEROFALLCLK, 0, 0 },
42595 { "HEROFALLCMB", HEROFALLCMB, 0, 0 },
42596 { "HEROMOVEFLAGS", HEROMOVEFLAGS, 0, 0 },
42597 { "ITEMFALLCLK", ITEMFALLCLK, 0, 0 },
42598 { "ITEMFALLCMB", ITEMFALLCMB, 0, 0 },
42599 { "ITEMMOVEFLAGS", ITEMMOVEFLAGS, 0, 0 },
42600 { "LWPNFALLCLK", LWPNFALLCLK, 0, 0 },
42601 { "LWPNFALLCMB", LWPNFALLCMB, 0, 0 },
42602 { "LWPNMOVEFLAGS", LWPNMOVEFLAGS, 0, 0 },
42603 { "EWPNFALLCLK", EWPNFALLCLK, 0, 0 },
42604 { "EWPNFALLCMB", EWPNFALLCMB, 0, 0 },
42605 { "EWPNMOVEFLAGS", EWPNMOVEFLAGS, 0, 0 },
42606 { "NPCFALLCLK", NPCFALLCLK, 0, 0 },
42607 { "NPCFALLCMB", NPCFALLCMB, 0, 0 },
42608 { "NPCMOVEFLAGS", NPCMOVEFLAGS, 0, 0 },
42609 { "ISBLANKTILE", ISBLANKTILE, 0, 0 },
42610 { "LWPNSPECIAL", LWPNSPECIAL, 0, 0 },
42611 { "DMAPDATAASUBSCRIPT", DMAPDATAASUBSCRIPT, 0, 0 },
42612 { "DMAPDATAPSUBSCRIPT", DMAPDATAPSUBSCRIPT, 0, 0 },
42613 { "DMAPDATASUBINITD", DMAPDATASUBINITD, 0, 0 },
42614 { "MODULEGETINT", MODULEGETINT, 0, 0 },
42615 { "MODULEGETSTR", MODULEGETSTR, 0, 0 },
42616 { "NPCORIGINALHP", NPCORIGINALHP, 0, 0 },
42617 { "DMAPDATAMAPSCRIPT", DMAPDATAMAPSCRIPT, 0, 0 },
42618 { "DMAPDATAMAPINITD", DMAPDATAMAPINITD, 0, 0 },
42619 { "CLOCKCLK", CLOCKCLK, 0, 0 },
42620 { "CLOCKACTIVE", CLOCKACTIVE, 0, 0 },
42621 { "NPCHITDIR", NPCHITDIR, 0, 0 },
42622 { "DMAPDATAFLAGARR", DMAPDATAFLAGARR, 0, 0 },
42623 { "LINKCSET", LINKCSET, 0, 0 },
42624 { "NPCSLIDECLK", NPCSLIDECLK, 0, 0 },
42625 { "NPCFADING", NPCFADING, 0, 0 },
42626 { "DISTANCE", DISTANCE, 0, 0 },
42627 { "STDARR", STDARR, 0, 0 },
42628 { "GHOSTARR", GHOSTARR, 0, 0 },
42629 { "TANGOARR", TANGOARR, 0, 0 },
42630 { "NPCHALTCLK", NPCHALTCLK, 0, 0 },
42631 { "NPCMOVESTATUS", NPCMOVESTATUS, 0, 0 },
42632 { "DISTANCESCALE", DISTANCESCALE, 0, 0 },
42633 { "DMAPDATACHARTED", DMAPDATACHARTED, 0, 0 },
42634 { "REFDIRECTORY", REFDIRECTORY, 0, 0 },
42635 { "DIRECTORYSIZE", DIRECTORYSIZE, 0, 0 },
42636 { "LONGDISTANCE", LONGDISTANCE, 0, 0 },
42637 { "LONGDISTANCESCALE", LONGDISTANCESCALE, 0, 0 },
42638 { "COMBOED", COMBOED, 0, 0 },
42639 { "MAPDATACOMBOED", MAPDATACOMBOED, 0, 0 },
42640 { "COMBODEFFECT", COMBODEFFECT, 0, 0 },
42641 { "SCREENSECRETSTRIGGERED", SCREENSECRETSTRIGGERED, 0, 0 },
42642 { "ITEMDIR", ITEMDIR, 0, 0 },
42643 { "NPCFRAME", NPCFRAME, 0, 0 },
42644 { "LINKITEMX", LINKITEMX, 0, 0 },
42645 { "LINKITEMY", LINKITEMY, 0, 0 },
42646 { "ACTIVESSSPEED", ACTIVESSSPEED, 0, 0 },
42647 { "HEROISWARPING", HEROISWARPING, 0, 0 },
42648 { "ITEMGLOWRAD", ITEMGLOWRAD, 0, 0 },
42649 { "NPCGLOWRAD", NPCGLOWRAD, 0, 0 },
42650 { "LWPNGLOWRAD", LWPNGLOWRAD, 0, 0 },
42651 { "EWPNGLOWRAD", EWPNGLOWRAD, 0, 0 },
42652 { "ITEMGLOWSHP", ITEMGLOWSHP, 0, 0 },
42653 { "NPCGLOWSHP", NPCGLOWSHP, 0, 0 },
42654 { "LWPNGLOWSHP", LWPNGLOWSHP, 0, 0 },
42655 { "EWPNGLOWSHP", EWPNGLOWSHP, 0, 0 },
42656 { "ITEMENGINEANIMATE", ITEMENGINEANIMATE, 0, 0 },
42657 { "REFRNG", REFRNG, 0, 0 },
42658 { "LWPNUNBL", LWPNUNBL, 0, 0 },
42659 { "EWPNUNBL", EWPNUNBL, 0, 0 },
42660 { "NPCSHADOWSPR", NPCSHADOWSPR, 0, 0 },
42661 { "LWPNSHADOWSPR", LWPNSHADOWSPR, 0, 0 },
42662 { "EWPNSHADOWSPR", EWPNSHADOWSPR, 0, 0 },
42663 { "ITEMSHADOWSPR", ITEMSHADOWSPR, 0, 0 },
42664 { "NPCSPAWNSPR", NPCSPAWNSPR, 0, 0 },
42665 { "NPCDEATHSPR", NPCDEATHSPR, 0, 0 },
42666 { "NPCDSHADOWSPR", NPCDSHADOWSPR, 0, 0 },
42667 { "NPCDSPAWNSPR", NPCDSPAWNSPR, 0, 0 },
42668 { "NPCDDEATHSPR", NPCDDEATHSPR, 0, 0 },
42669
42670 { "COMBOLAYERR", COMBOLAYERR, 0, 0 },
42671 { "COMBODATTRISHORTS", COMBODATTRISHORTS, 0, 0 },
42672
42673 { "PUSHBLOCKLAYER", PUSHBLOCKLAYER, 0, 0 },
42674 { "LINKGRABBED", LINKGRABBED, 0, 0 },
42675 { "HEROBUNNY", HEROBUNNY, 0, 0 },
42676
42677 { "GAMELSWITCH", GAMELSWITCH, 0, 0 },
42678 { "GAMEBOTTLEST", GAMEBOTTLEST, 0, 0 },
42679
42680 { "REFBOTTLETYPE", REFBOTTLETYPE, 0, 0 },
42681 { "REFBOTTLESHOP", REFBOTTLESHOP, 0, 0 },
42682 { "BOTTLECOUNTER", BOTTLECOUNTER, 0, 0 },
42683 { "BOTTLEAMOUNT", BOTTLEAMOUNT, 0, 0 },
42684 { "BOTTLEPERCENT", BOTTLEPERCENT, 0, 0 },
42685 { "BOTTLEFLAGS", BOTTLEFLAGS, 0, 0 },
42686 { "BOTTLENEXT", BOTTLENEXT, 0, 0 },
42687 { "BSHOPFILL", BSHOPFILL, 0, 0 },
42688 { "BSHOPCOMBO", BSHOPCOMBO, 0, 0 },
42689 { "BSHOPCSET", BSHOPCSET, 0, 0 },
42690 { "BSHOPPRICE", BSHOPPRICE, 0, 0 },
42691 { "BSHOPSTR", BSHOPSTR, 0, 0 },
42692 { "COMBODUSRFLAGARR", COMBODUSRFLAGARR, 0, 0 },
42693 { "COMBODGENFLAGARR", COMBODGENFLAGARR, 0, 0 },
42694 { "HERORESPAWNX", HERORESPAWNX, 0, 0 },
42695 { "HERORESPAWNY", HERORESPAWNY, 0, 0 },
42696 { "HERORESPAWNDMAP", HERORESPAWNDMAP, 0, 0 },
42697 { "HERORESPAWNSCR", HERORESPAWNSCR, 0, 0 },
42698 { "IDATAUSESOUND2", IDATAUSESOUND2, 0, 0 },
42699 { "HEROSWITCHTIMER", HEROSWITCHTIMER, 0, 0 },
42700 { "HEROSWITCHMAXTIMER", HEROSWITCHMAXTIMER, 0, 0 },
42701 { "NPCSWHOOKED", NPCSWHOOKED, 0, 0 },
42702 { "GAMEMISCSPR", GAMEMISCSPR, 0, 0 },
42703 { "GAMEMISCSFX", GAMEMISCSFX, 0, 0 },
42704 { "HEROTOTALDYOFFS", HEROTOTALDYOFFS, 0, 0 },
42705 { "NPCTOTALDYOFFS", NPCTOTALDYOFFS, 0, 0 },
42706 { "LWPNTOTALDYOFFS", LWPNTOTALDYOFFS, 0, 0 },
42707 { "EWPNTOTALDYOFFS", EWPNTOTALDYOFFS, 0, 0 },
42708 { "LWSWHOOKED", LWSWHOOKED, 0, 0 },
42709 { "EWSWHOOKED", EWSWHOOKED, 0, 0 },
42710 { "ITMSWHOOKED", ITMSWHOOKED, 0, 0 },
42711 { "DEBUGTESTING", DEBUGTESTING, 0, 0 },
42712 { "GAMEMAXCHEAT", GAMEMAXCHEAT, 0, 0 },
42713 { "SHOWNMSG", SHOWNMSG, 0, 0 },
42714 { "COMBODTRIGGERBUTTON", COMBODTRIGGERBUTTON, 0, 0 },
42715 { "REFGENERICDATA", REFGENERICDATA, 0, 0 },
42716 { "GENDATARUNNING", GENDATARUNNING, 0, 0 },
42717 { "GENDATASIZE", GENDATASIZE, 0, 0 },
42718 { "GENDATAEXITSTATE", GENDATAEXITSTATE, 0, 0 },
42719 { "GENDATADATA", GENDATADATA, 0, 0 },
42720 { "GENDATAINITD", GENDATAINITD, 0, 0 },
42721 { "GENDATARELOADSTATE", GENDATARELOADSTATE, 0, 0 },
42722 { "COMBODCSET2FLAGS", COMBODCSET2FLAGS, 0, 0 },
42723 { "HEROIMMORTAL", HEROIMMORTAL, 0, 0 },
42724 { "NPCCANFLICKER", NPCCANFLICKER, 0, 0 },
42725 { "NPCDROWNCLK", NPCDROWNCLK, 0, 0 },
42726 { "NPCDROWNCMB", NPCDROWNCMB, 0, 0 },
42727 { "ITEMDROWNCLK", ITEMDROWNCLK, 0, 0 },
42728 { "ITEMDROWNCMB", ITEMDROWNCMB, 0, 0 },
42729 { "LWPNDROWNCLK", LWPNDROWNCLK, 0, 0 },
42730 { "LWPNDROWNCMB", LWPNDROWNCMB, 0, 0 },
42731 { "EWPNDROWNCLK", EWPNDROWNCLK, 0, 0 },
42732 { "EWPNDROWNCMB", EWPNDROWNCMB, 0, 0 },
42733 { "HERODROWNCLK", HERODROWNCLK, 0, 0 },
42734 { "HERODROWNCMB", HERODROWNCMB, 0, 0 },
42735 { "NPCFAKEZ", NPCFAKEZ, 0, 0 },
42736 { "ITEMFAKEZ", ITEMFAKEZ, 0, 0 },
42737 { "LWPNFAKEZ", LWPNFAKEZ, 0, 0 },
42738 { "EWPNFAKEZ", EWPNFAKEZ, 0, 0 },
42739 { "HEROFAKEZ", HEROFAKEZ, 0, 0 },
42740 { "NPCFAKEJUMP", NPCFAKEJUMP, 0, 0 },
42741 { "ITEMFAKEJUMP", ITEMFAKEJUMP, 0, 0 },
42742 { "LWPNFAKEJUMP", LWPNFAKEJUMP, 0, 0 },
42743 { "EWPNFAKEJUMP", EWPNFAKEJUMP, 0, 0 },
42744 { "HEROFAKEJUMP", HEROFAKEJUMP, 0, 0 },
42745 { "HEROSHADOWXOFS", HEROSHADOWXOFS, 0, 0 },
42746 { "HEROSHADOWYOFS", HEROSHADOWYOFS, 0, 0 },
42747 { "NPCSHADOWXOFS", NPCSHADOWXOFS, 0, 0 },
42748 { "NPCSHADOWYOFS", NPCSHADOWYOFS, 0, 0 },
42749 { "ITEMSHADOWXOFS", ITEMSHADOWXOFS, 0, 0 },
42750 { "ITEMSHADOWYOFS", ITEMSHADOWYOFS, 0, 0 },
42751 { "LWPNSHADOWXOFS", LWPNSHADOWXOFS, 0, 0 },
42752 { "LWPNSHADOWYOFS", LWPNSHADOWYOFS, 0, 0 },
42753 { "EWPNSHADOWXOFS", EWPNSHADOWXOFS, 0, 0 },
42754 { "EWPNSHADOWYOFS", EWPNSHADOWYOFS, 0, 0 },
42755 { "LWPNDEGANGLE", LWPNDEGANGLE, 0, 0 },
42756 { "EWPNDEGANGLE", EWPNDEGANGLE, 0, 0 },
42757 { "LWPNVX", LWPNVX, 0, 0 },
42758 { "LWPNVY", LWPNVY, 0, 0 },
42759 { "EWPNVX", EWPNVX, 0, 0 },
42760 { "EWPNVY", EWPNVY, 0, 0 },
42761 { "LWPNAUTOROTATE", LWPNAUTOROTATE, 0, 0 },
42762 { "EWPNAUTOROTATE", EWPNAUTOROTATE, 0, 0 },
42763 { "IDATACOSTCOUNTER2", IDATACOSTCOUNTER2, 0, 0 },
42764 { "IDATAMAGICTIMER2", IDATAMAGICTIMER2, 0, 0 },
42765 { "IDATACOST2", IDATACOST2, 0, 0 },
42766 { "IDATAVALIDATE2", IDATAVALIDATE2, 0, 0 },
42767 { "MESSAGEDATATEXTLEN", MESSAGEDATATEXTLEN, 0, 0 },
42768 { "LWPNFLAGS", LWPNFLAGS, 0, 0 },
42769 { "EWPNFLAGS", EWPNFLAGS, 0, 0 },
42770 { "REFSTACK", REFSTACK, 0, 0 },
42771 { "STACKSIZE", STACKSIZE, 0, 0 },
42772 { "STACKFULL", STACKFULL, 0, 0 },
42773 { "ITEMFORCEGRAB", ITEMFORCEGRAB, 0, 0 },
42774 { "COMBODTRIGGERITEM", COMBODTRIGGERITEM, 0, 0 },
42775 { "COMBODTRIGGERTIMER", COMBODTRIGGERTIMER, 0, 0 },
42776 { "COMBODTRIGGERSFX", COMBODTRIGGERSFX, 0, 0 },
42777 { "COMBODTRIGGERCHANGECMB", COMBODTRIGGERCHANGECMB, 0, 0 },
42778 { "SCREENEXSTATED", SCREENEXSTATED, 0, 0 },
42779 { "MAPDATAEXSTATED", MAPDATAEXSTATED, 0, 0 },
42780 { "HEROSTANDING", HEROSTANDING, 0, 0 },
42781 { "COMBODTRIGGERPROX", COMBODTRIGGERPROX, 0, 0 },
42782 { "COMBODTRIGGERLIGHTBEAM", COMBODTRIGGERLIGHTBEAM, 0, 0 },
42783 { "COMBODTRIGGERCTR", COMBODTRIGGERCTR, 0, 0 },
42784 { "COMBODTRIGGERCTRAMNT", COMBODTRIGGERCTRAMNT, 0, 0 },
42785 { "GENDATAEVENTSTATE", GENDATAEVENTSTATE, 0, 0 },
42786 { "GAMEEVENTDATA", GAMEEVENTDATA, 0, 0 },
42787 { "ITEMDROPPEDBY", ITEMDROPPEDBY, 0, 0 },
42788 { "GAMEGSWITCH", GAMEGSWITCH, 0, 0 },
42789
42790 { "COMBODTRIGGERCOOLDOWN", COMBODTRIGGERCOOLDOWN, 0, 0 },
42791 { "COMBODTRIGGERCOPYCAT", COMBODTRIGGERCOPYCAT, 0, 0 },
42792 { "COMBODTRIGITEMPICKUP", COMBODTRIGITEMPICKUP, 0, 0 },
42793 { "COMBODTRIGEXSTATE", COMBODTRIGEXSTATE, 0, 0 },
42794 { "COMBODTRIGSPAWNENEMY", COMBODTRIGSPAWNENEMY, 0, 0 },
42795 { "COMBODTRIGSPAWNITEM", COMBODTRIGSPAWNITEM, 0, 0 },
42796 { "COMBODTRIGCSETCHANGE", COMBODTRIGCSETCHANGE, 0, 0 },
42797 { "COMBODLIFTGFXCOMBO", COMBODLIFTGFXCOMBO, 0, 0 },
42798 { "COMBODLIFTGFXCCSET", COMBODLIFTGFXCCSET, 0, 0 },
42799 { "COMBODLIFTUNDERCMB", COMBODLIFTUNDERCMB, 0, 0 },
42800 { "COMBODLIFTUNDERCS", COMBODLIFTUNDERCS, 0, 0 },
42801 { "COMBODLIFTDAMAGE", COMBODLIFTDAMAGE, 0, 0 },
42802 { "COMBODLIFTLEVEL", COMBODLIFTLEVEL, 0, 0 },
42803 { "COMBODLIFTITEM", COMBODLIFTITEM, 0, 0 },
42804 { "COMBODLIFTFLAGS", COMBODLIFTFLAGS, 0, 0 },
42805 { "COMBODLIFTGFXTYPE", COMBODLIFTGFXTYPE, 0, 0 },
42806 { "COMBODLIFTGFXSPRITE", COMBODLIFTGFXSPRITE, 0, 0 },
42807 { "COMBODLIFTSFX", COMBODLIFTSFX, 0, 0 },
42808 { "COMBODLIFTBREAKSPRITE", COMBODLIFTBREAKSPRITE, 0, 0 },
42809 { "COMBODLIFTBREAKSFX", COMBODLIFTBREAKSFX, 0, 0 },
42810 { "COMBODLIFTHEIGHT", COMBODLIFTHEIGHT, 0, 0 },
42811 { "COMBODLIFTTIME", COMBODLIFTTIME, 0, 0 },
42812 { "CLASS_THISKEY", CLASS_THISKEY, 0, 0 },
42813 { "ZELDABETATYPE", ZELDABETATYPE, 0, 0 },
42814 { "HEROCOYOTETIME", HEROCOYOTETIME, 0, 0 },
42815 { "FFCLASTCHANGERX", FFCLASTCHANGERX, 0, 0 },
42816 { "FFCLASTCHANGERY", FFCLASTCHANGERY, 0, 0 },
42817 { "LWPNTIMEOUT", LWPNTIMEOUT, 0, 0 },
42818 { "EWPNTIMEOUT", EWPNTIMEOUT, 0, 0 },
42819 { "COMBODTRIGGERLSTATE", COMBODTRIGGERLSTATE, 0, 0 },
42820 { "COMBODTRIGGERGSTATE", COMBODTRIGGERGSTATE, 0, 0 },
42821 { "COMBODTRIGGERGTIMER", COMBODTRIGGERGTIMER, 0, 0 },
42822 { "GAMEMOUSECURSOR", GAMEMOUSECURSOR, 0, 0 },
42823 { "COMBODTRIGGERGENSCRIPT", COMBODTRIGGERGENSCRIPT, 0, 0 },
42824 { "COMBODTRIGGERGROUP", COMBODTRIGGERGROUP, 0, 0 },
42825 { "COMBODTRIGGERGROUPVAL", COMBODTRIGGERGROUPVAL, 0, 0 },
42826 { "HEROLIFTEDWPN", HEROLIFTEDWPN, 0, 0 },
42827 { "HEROLIFTTIMER", HEROLIFTTIMER, 0, 0 },
42828 { "HEROLIFTMAXTIMER", HEROLIFTMAXTIMER, 0, 0 },
42829 { "HEROLIFTHEIGHT", HEROLIFTHEIGHT, 0, 0 },
42830 { "HEROHAMMERSTATE", HEROHAMMERSTATE, 0, 0 },
42831 { "HEROLIFTFLAGS", HEROLIFTFLAGS, 0, 0 },
42832 { "COMBODLIFTWEAPONITEM", COMBODLIFTWEAPONITEM, 0, 0 },
42833 { "LWPNDEATHITEM", LWPNDEATHITEM, 0, 0 },
42834 { "LWPNDEATHDROPSET", LWPNDEATHDROPSET, 0, 0 },
42835 { "LWPNDEATHIPICKUP", LWPNDEATHIPICKUP, 0, 0 },
42836 { "LWPNDEATHSPRITE", LWPNDEATHSPRITE, 0, 0 },
42837 { "LWPNDEATHSFX", LWPNDEATHSFX, 0, 0 },
42838 { "EWPNDEATHITEM", EWPNDEATHITEM, 0, 0 },
42839 { "EWPNDEATHDROPSET", EWPNDEATHDROPSET, 0, 0 },
42840 { "EWPNDEATHIPICKUP", EWPNDEATHIPICKUP, 0, 0 },
42841 { "EWPNDEATHSPRITE", EWPNDEATHSPRITE, 0, 0 },
42842 { "EWPNDEATHSFX", EWPNDEATHSFX, 0, 0 },
42843
42844 { "REFPALDATA", REFPALDATA, 0, 0 },
42845
42846 { "PALDATACOLOR", PALDATACOLOR, 0, 0 },
42847 { "PALDATAR", PALDATAR, 0, 0 },
42848 { "PALDATAG", PALDATAG, 0, 0 },
42849 { "PALDATAB", PALDATAB, 0, 0 },
42850
42851 { "DMAPDATALOOPSTART", DMAPDATALOOPSTART, 0, 0 },
42852 { "DMAPDATALOOPEND", DMAPDATALOOPEND, 0, 0 },
42853 { "DMAPDATAXFADEIN", DMAPDATAXFADEIN, 0, 0 },
42854 { "DMAPDATAXFADEOUT", DMAPDATAXFADEOUT, 0, 0 },
42855 { "MUSICUPDATECOND", MUSICUPDATECOND, 0, 0 },
42856 { "MUSICUPDATEFLAGS", MUSICUPDATEFLAGS, 0, 0 },
42857 { "RESRVD_VAR_MOOSH07", RESRVD_VAR_MOOSH07, 0, 0 },
42858 { "RESRVD_VAR_MOOSH08", RESRVD_VAR_MOOSH08, 0, 0 },
42859 { "RESRVD_VAR_MOOSH09", RESRVD_VAR_MOOSH09, 0, 0 },
42860 { "RESRVD_VAR_MOOSH10", RESRVD_VAR_MOOSH10, 0, 0 },
42861 { "RESRVD_VAR_MOOSH11", RESRVD_VAR_MOOSH11, 0, 0 },
42862 { "RESRVD_VAR_MOOSH12", RESRVD_VAR_MOOSH12, 0, 0 },
42863 { "RESRVD_VAR_MOOSH13", RESRVD_VAR_MOOSH13, 0, 0 },
42864 { "RESRVD_VAR_MOOSH14", RESRVD_VAR_MOOSH14, 0, 0 },
42865 { "RESRVD_VAR_MOOSH15", RESRVD_VAR_MOOSH15, 0, 0 },
42866 { "RESRVD_VAR_MOOSH16", RESRVD_VAR_MOOSH16, 0, 0 },
42867 { "RESRVD_VAR_MOOSH17", RESRVD_VAR_MOOSH17, 0, 0 },
42868 { "RESRVD_VAR_MOOSH18", RESRVD_VAR_MOOSH18, 0, 0 },
42869 { "RESRVD_VAR_MOOSH19", RESRVD_VAR_MOOSH19, 0, 0 },
42870 { "RESRVD_VAR_MOOSH20", RESRVD_VAR_MOOSH20, 0, 0 },
42871 { "RESRVD_VAR_MOOSH21", RESRVD_VAR_MOOSH21, 0, 0 },
42872 { "RESRVD_VAR_MOOSH22", RESRVD_VAR_MOOSH22, 0, 0 },
42873 { "RESRVD_VAR_MOOSH23", RESRVD_VAR_MOOSH23, 0, 0 },
42874 { "RESRVD_VAR_MOOSH24", RESRVD_VAR_MOOSH24, 0, 0 },
42875 { "RESRVD_VAR_MOOSH25", RESRVD_VAR_MOOSH25, 0, 0 },
42876 { "RESRVD_VAR_MOOSH26", RESRVD_VAR_MOOSH26, 0, 0 },
42877 { "RESRVD_VAR_MOOSH27", RESRVD_VAR_MOOSH27, 0, 0 },
42878 { "RESRVD_VAR_MOOSH28", RESRVD_VAR_MOOSH28, 0, 0 },
42879 { "RESRVD_VAR_MOOSH29", RESRVD_VAR_MOOSH29, 0, 0 },
42880 { "RESRVD_VAR_MOOSH30", RESRVD_VAR_MOOSH30, 0, 0 },
42881 { "DMAPDATAMIRRDMAP", DMAPDATAMIRRDMAP, 0, 0 },
42882 { "IDATAGRADUAL", IDATAGRADUAL, 0, 0 },
42883 { "IDATASPRSCRIPT", IDATASPRSCRIPT, 0, 0 },
42884 { "IDATAPSOUND", IDATAPSOUND, 0, 0 },
42885 { "IDATACONSTSCRIPT", IDATACONSTSCRIPT, 0, 0 },
42886 { "IDATASSWIMDISABLED", IDATASSWIMDISABLED, 0, 0 },
42887 { "IDATABUNNYABLE", IDATABUNNYABLE, 0, 0 },
42888 { "IDATAJINXIMMUNE", IDATAJINXIMMUNE, 0, 0 },
42889 { "IDATAJINXSWAP", IDATAJINXSWAP, 0, 0 },
42890 { "SPRITEDATAFLCSET", SPRITEDATAFLCSET, 0, 0 },
42891 { "SPRITEDATAFLAGS", SPRITEDATAFLAGS, 0, 0 },
42892 { "SPRITEDATAID", SPRITEDATAID, 0, 0 },
42893 { "CLASS_THISKEY2", CLASS_THISKEY2, 0, 0 },
42894 { "RESRVD_VAR_Z3_01", RESRVD_VAR_Z3_01, 0, 0 },
42895 { "RESRVD_VAR_Z3_02", RESRVD_VAR_Z3_02, 0, 0 },
42896 { "RESRVD_VAR_Z3_03", RESRVD_VAR_Z3_03, 0, 0 },
42897 { "RESRVD_VAR_Z3_04", RESRVD_VAR_Z3_04, 0, 0 },
42898 { "RESRVD_VAR_Z3_05", RESRVD_VAR_Z3_05, 0, 0 },
42899 { "RESRVD_VAR_Z3_06", RESRVD_VAR_Z3_06, 0, 0 },
42900 { "RESRVD_VAR_Z3_07", RESRVD_VAR_Z3_07, 0, 0 },
42901 { "RESRVD_VAR_Z3_08", RESRVD_VAR_Z3_08, 0, 0 },
42902 { "RESRVD_VAR_Z3_09", RESRVD_VAR_Z3_09, 0, 0 },
42903 { "RESRVD_VAR_Z3_10", RESRVD_VAR_Z3_10, 0, 0 },
42904 { "RESRVD_VAR_Z3_11", RESRVD_VAR_Z3_11, 0, 0 },
42905 { "RESRVD_VAR_Z3_12", RESRVD_VAR_Z3_12, 0, 0 },
42906 { "RESRVD_VAR_Z3_13", RESRVD_VAR_Z3_13, 0, 0 },
42907 { "RESRVD_VAR_Z3_14", RESRVD_VAR_Z3_14, 0, 0 },
42908 { "RESRVD_VAR_Z3_15", RESRVD_VAR_Z3_15, 0, 0 },
42909 { "RESRVD_VAR_Z3_16", RESRVD_VAR_Z3_16, 0, 0 },
42910 { "LWPNLIFTLEVEL", LWPNLIFTLEVEL, 0, 0},
42911 { "LWPNLIFTTIME", LWPNLIFTTIME, 0, 0},
42912 { "LWPNLIFTHEIGHT", LWPNLIFTHEIGHT, 0, 0},
42913 { "EWPNLIFTLEVEL", EWPNLIFTLEVEL, 0, 0},
42914 { "EWPNLIFTTIME", EWPNLIFTTIME, 0, 0},
42915 { "EWPNLIFTHEIGHT", EWPNLIFTHEIGHT, 0, 0},
42916 { "HEROSHIELDJINX", HEROSHIELDJINX, 0, 0},
42917 { "MAPDATALENSSHOWS", MAPDATALENSSHOWS, 0, 0},
42918 { "MAPDATALENSHIDES", MAPDATALENSHIDES, 0, 0},
42919 { "SCREENLENSSHOWS", SCREENLENSSHOWS, 0, 0},
42920 { "SCREENLENSHIDES", SCREENLENSHIDES, 0, 0},
42921 { "GAMETRIGGROUPS", GAMETRIGGROUPS, 0, 0},
42922 { "RESRVD_VAR_EMILY43", RESRVD_VAR_EMILY43, 0, 0},
42923 { "RESRVD_VAR_EMILY44", RESRVD_VAR_EMILY44, 0, 0},
42924 { "RESRVD_VAR_EMILY45", RESRVD_VAR_EMILY45, 0, 0},
42925 { "RESRVD_VAR_EMILY46", RESRVD_VAR_EMILY46, 0, 0},
42926 { "RESRVD_VAR_EMILY47", RESRVD_VAR_EMILY47, 0, 0},
42927 { "RESRVD_VAR_EMILY48", RESRVD_VAR_EMILY48, 0, 0},
42928 { "RESRVD_VAR_EMILY49", RESRVD_VAR_EMILY49, 0, 0},
42929 { "RESRVD_VAR_EMILY50", RESRVD_VAR_EMILY50, 0, 0},
42930 { "RESRVD_VAR_EMILY51", RESRVD_VAR_EMILY51, 0, 0},
42931 { "RESRVD_VAR_EMILY52", RESRVD_VAR_EMILY52, 0, 0},
42932 { "RESRVD_VAR_EMILY53", RESRVD_VAR_EMILY53, 0, 0},
42933 { "RESRVD_VAR_EMILY54", RESRVD_VAR_EMILY54, 0, 0},
42934 { "RESRVD_VAR_EMILY55", RESRVD_VAR_EMILY55, 0, 0},
42935 { "RESRVD_VAR_EMILY56", RESRVD_VAR_EMILY56, 0, 0},
42936 { "RESRVD_VAR_EMILY57", RESRVD_VAR_EMILY57, 0, 0},
42937 { "RESRVD_VAR_EMILY58", RESRVD_VAR_EMILY58, 0, 0},
42938 { "RESRVD_VAR_EMILY59", RESRVD_VAR_EMILY59, 0, 0},
42939 { "RESRVD_VAR_EMILY60", RESRVD_VAR_EMILY60, 0, 0},
42940 { "PORTALX", PORTALX, 0, 0},
42941 { "PORTALY", PORTALY, 0, 0},
42942 { "PORTALDMAP", PORTALDMAP, 0, 0},
42943 { "PORTALSCREEN", PORTALSCREEN, 0, 0},
42944 { "PORTALACLK", PORTALACLK, 0, 0},
42945 { "PORTALAFRM", PORTALAFRM, 0, 0},
42946 { "PORTALOTILE", PORTALOTILE, 0, 0},
42947 { "PORTALASPD", PORTALASPD, 0, 0},
42948 { "PORTALFRAMES", PORTALFRAMES, 0, 0},
42949 { "PORTALSAVED", PORTALSAVED, 0, 0},
42950 { "PORTALCLOSEDIS", PORTALCLOSEDIS, 0, 0},
42951 { "REFPORTAL", REFPORTAL, 0, 0},
42952 { "REFSAVPORTAL", REFSAVPORTAL, 0, 0},
42953 { "PORTALWARPSFX", PORTALWARPSFX, 0, 0},
42954 { "PORTALWARPVFX", PORTALWARPVFX, 0, 0},
42955 { "SAVEDPORTALX", SAVEDPORTALX, 0, 0},
42956 { "SAVEDPORTALY", SAVEDPORTALY, 0, 0},
42957 { "SAVEDPORTALSRCDMAP", SAVEDPORTALSRCDMAP, 0, 0},
42958 { "SAVEDPORTALDESTDMAP", SAVEDPORTALDESTDMAP, 0, 0},
42959 { "SAVEDPORTALSRCSCREEN", SAVEDPORTALSRCSCREEN, 0, 0},
42960 { "SAVEDPORTALWARPSFX", SAVEDPORTALWARPSFX, 0, 0},
42961 { "SAVEDPORTALWARPVFX", SAVEDPORTALWARPVFX, 0, 0},
42962 { "SAVEDPORTALSPRITE", SAVEDPORTALSPRITE, 0, 0},
42963 { "SAVEDPORTALPORTAL", SAVEDPORTALPORTAL, 0, 0},
42964 { "PORTALCOUNT", PORTALCOUNT, 0, 0},
42965 { "SAVEDPORTALCOUNT", SAVEDPORTALCOUNT, 0, 0},
42966 { "SAVEDPORTALDSTSCREEN", SAVEDPORTALDSTSCREEN, 0, 0},
42967
42968 { " ", -1, 0, 0 }
42969 };
42970
42971
42972
42973 ///----------------------------------------------------------------------------------------------------//
42974 //Debugger and Logging Consoles
42975
42976 template <typename ...Params>
42977 void FFScript::ZScriptConsole(int32_t attributes,const char *format, Params&&... params)
42978 {
42979 //if ( open )
42980 {
42981 zscript_coloured_console.Create("ZQuest Creator Logging Console", 600, 200, NULL, NULL);
42982 zscript_coloured_console.cls(CConsoleLoggerEx::COLOR_BACKGROUND_BLACK);
42983 zscript_coloured_console.gotoxy(0,0);
42984 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
42985 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"ZQuest Creator Logging Console\n");
42986
42987 zscript_coloured_console.cprintf( attributes, format, std::forward<Params>(params)...);
42988 }
42989 //else
42990 //{
42991 //close
42992 // zscript_coloured_console.Close();
42993 //}
42994 }
42995
42996 123 void clearConsole()
42997 {
42998 123 zscript_coloured_console.cls(CConsoleLoggerEx::COLOR_BACKGROUND_BLACK);
42999 123 zscript_coloured_console.gotoxy(0,0);
43000
43001 123 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
43002 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"\n _____ ____ __ \n");
43003 123 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
43004 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK," /__ / / __ \\__ _____ _____/ /_\n");
43005 123 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
43006 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK," / / / / / / / / / _ \\/ ___/ __/\n");
43007 123 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
43008 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK," / /__/ /_/ / /_/ / __(__ ) /_ \n");
43009 123 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
43010 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK," /____/\\___\\_\\__,_/\\___/____/\\__/\n\n");
43011
43012 123 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
43013 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Quest Data Logging & ZScript Debug Console\n");
43014
43015 123 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE |CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
43016 123 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Running: %s\n", getProgramVerStr());
43017
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 7 times.
123 if ( FFCore.getQuestHeaderInfo(vZelda) > 0 )
43018 {
43019 7 char const* verstr = QHeader.getVerStr();
43020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(verstr[0])
43021 {
43022 7 auto vercmp = QHeader.compareVer();
43023 7 auto astatecmp = compare(int32_t(QHeader.getAlphaState()), ALPHA_STATE);
43024 7 auto avercmp = compare(QHeader.getAlphaVer(), ALPHA_VER);
43025 7 auto timecmp = QHeader.compareDate();
43026
5/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
7 if(!(vercmp || astatecmp || avercmp))
43027 {
43028
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!timecmp || !QHeader.new_version_is_nightly)
43029 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE |CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
43030 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Quest Made in this build\n", verstr);
43031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(timecmp < 0)
43032 {
43033 1 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE |CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
43034 1 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Quest Made in an earlier nightly of the same build\n", verstr);
43035 1 }
43036 else
43037 {
43038 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE |CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
43039 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Quest Made in an LATER nightly of the same build!\n"
43040 "This may be unsafe to play in this version!\n", verstr);
43041 }
43042 1 }
43043 6 else zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE |CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
43044 6 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Quest Made in: %s\n", verstr);
43045 7 }
43046 7 }
43047 123 }
43048 void FFScript::ZScriptConsole(bool open)
43049 {
43050 if ( open )
43051 {
43052 zscript_coloured_console.Create("ZScript Debug Console", 600, 200, NULL, NULL);
43053 clearConsole();
43054 zscript_debugger = 1;
43055 }
43056 else
43057 {
43058 zscript_coloured_console.Close();
43059 zscript_debugger = 0;
43060 }
43061 zc_set_config("CONSOLE","ZScript_Debugger",zscript_debugger);
43062 }
43063
43064 void FFScript::ZASMPrint(bool open)
43065 {
43066 if(SKIPZASMPRINT()) return;
43067 zprint("%s ZASM Console\n", open ? "Opening" : "Closing");
43068 if ( open )
43069 {
43070 coloured_console.Create("ZASM Debugger", 600, 200, NULL, NULL);
43071 coloured_console.cls(CConsoleLoggerEx::COLOR_BACKGROUND_BLACK);
43072 coloured_console.gotoxy(0,0);
43073 coloured_console.safeprint( CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
43074 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"ZASM Stack Trace:\n");
43075 //coloured_console.SetAsDefaultOutput();
43076 zasm_debugger = 1;
43077 zasm_break_mode = ZASM_BREAK_HALT;
43078 }
43079 else
43080 {
43081 //close
43082 coloured_console.Close();
43083 zasm_debugger = 0;
43084 }
43085 zc_set_config("CONSOLE","print_ZASM",zasm_debugger);
43086 }
43087
43088 std::string ZASMVarToString(int32_t arg)
43089 {
43090 for(int32_t q = 0; ZASMVars[q].id != -1; ++q)
43091 {
43092 if(ZASMVars[q].maxcount>0)
43093 {
43094 int32_t start = ZASMVars[q].id;
43095 int32_t mult = zc_max(1,ZASMVars[q].multiple);
43096 if(arg >= start && arg < start+(ZASMVars[q].maxcount*mult))
43097 {
43098 for(int32_t w = 0; w < ZASMVars[q].maxcount; ++w)
43099 {
43100 if(arg!=start+(w*mult)) continue;
43101
43102 char buf[64+1];
43103 if(strcmp(ZASMVars[q].name, "A")==0)
43104 sprintf(buf, "%s%d", ZASMVars[q].name, w+1);
43105 else sprintf(buf, "%s%d", ZASMVars[q].name, w);
43106 return string(buf);
43107 }
43108 }
43109 }
43110 else if(ZASMVars[q].id == arg) return string(ZASMVars[q].name);
43111 }
43112 return "(null)";
43113 }
43114
43115 void FFScript::ZASMPrintCommand(const word scommand)
43116 {
43117 if(SKIPZASMPRINT()) return;
43118 //if ( !zasm_debugger ) return;
43119
43120 script_command s_c = ZASMcommands[scommand];
43121
43122 if(s_c.args == 2)
43123 {
43124 coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
43125 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%14s: ", s_c.name);
43126
43127 if(s_c.arg1_type == 0)
43128 {
43129 coloured_console.cprintf( CConsoleLoggerEx::COLOR_WHITE |
43130 //CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %9d), ", s_v.name, get_register(sarg1));
43131 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"\t %s (val = %2d), ", ZASMVarToString(sarg1).c_str(), get_register(sarg1));
43132 }
43133 else
43134 {
43135 coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED |CConsoleLoggerEx::COLOR_INTENSITY |
43136 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %2d), ", "immediate", sarg1);
43137 }
43138 if(s_c.arg2_type == 0)
43139 {
43140 coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_INTENSITY |
43141 //CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %9d)\n", s_v.name, get_register(sarg2));
43142 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK, "\t %s (val = %2d)\n", ZASMVarToString(sarg2).c_str(), get_register(sarg2));
43143 }
43144 else
43145 {
43146 coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_INTENSITY |
43147 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %2d)\n", "immediate", sarg2);
43148 }
43149 }
43150 else if(s_c.args == 1)
43151 {
43152 coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
43153 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%14s: ", s_c.name);
43154
43155 if(s_c.arg1_type == 0)
43156 {
43157 coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_INTENSITY |
43158 //CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %9d)\n", s_v.name, get_register(sarg1));
43159 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"\t %w (val = %2d)\n", ZASMVarToString(sarg1).c_str(), get_register(sarg1));
43160 }
43161 else
43162 {
43163 coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_INTENSITY |
43164 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %2d)\n", "immediate", sarg1);
43165 }
43166 }
43167 else
43168 {
43169 coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
43170 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%14s\n",s_c.name);
43171 }
43172 //s_c.name is the string with the instruction
43173
43174 //coloured_console.print();
43175 }
43176
43177 void FFScript::ZASMPrintVarSet(const int32_t arg, int32_t argval)
43178 {
43179 if(SKIPZASMPRINT()) return;
43180
43181 //if ( !zasm_debugger ) return;
43182 // script_variable s_v = ZASMVars[arg];
43183 //s_v.name is the string with the instruction
43184 coloured_console.cprintf( CConsoleLoggerEx::COLOR_WHITE |
43185 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Set: %s\t",ZASMVarToString(arg).c_str());
43186 coloured_console.cprintf( CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
43187 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%d\n",argval);
43188 //coloured_console.print();
43189 }
43190
43191 void FFScript::ZASMPrintVarGet(const int32_t arg, int32_t argval)
43192 {
43193 if(SKIPZASMPRINT()) return;
43194
43195 //if ( !zasm_debugger ) return;
43196 // script_variable s_v = ZASMVars[arg];
43197 //s_v.name is the string with the instruction
43198 coloured_console.cprintf( CConsoleLoggerEx::COLOR_WHITE |
43199 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Get: %s\t",ZASMVarToString(arg).c_str());
43200 coloured_console.cprintf( CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
43201 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%d\n",argval);
43202 //coloured_console.print();
43203 }
43204
43205
43206
43207 ///----------------------------------------------------------------------------------------------------//
43208 //Tracing
43209
43210 3603 void FFScript::do_trace(bool v)
43211 {
43212 3603 int32_t temp = SH::get_arg(sarg1, v);
43213
43214 char tmp[100];
43215
1/2
✓ Branch 0 taken 3603 times.
✗ Branch 1 not taken.
3603 sprintf(tmp, (temp < 0 ? "%06d" : "%05d"), temp);
43216
1/2
✓ Branch 0 taken 3603 times.
✗ Branch 1 not taken.
3603 string s2(tmp);
43217
5/10
✓ Branch 0 taken 3603 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3603 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3603 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3603 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3603 times.
✗ Branch 9 not taken.
3603 s2 = s2.substr(0, s2.size() - 4) + "." + s2.substr(s2.size() - 4, 4) + "\n";
43218
1/2
✓ Branch 0 taken 3603 times.
✗ Branch 1 not taken.
3603 TraceScriptIDs();
43219
1/2
✓ Branch 0 taken 3603 times.
✗ Branch 1 not taken.
3603 al_trace("%s", s2.c_str());
43220
8/18
✓ Branch 0 taken 3603 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3603 times.
✓ Branch 4 taken 3603 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3603 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3603 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 3603 times.
✓ Branch 12 taken 9 times.
✓ Branch 13 taken 3594 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
7206 if (replay_is_active() && replay_get_meta_bool("script_trace"))
43221
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 replay_step_comment("trace: " + s2);
43222
43223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3603 times.
3603 if ( zscript_debugger )
43224 {
43225 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
43226 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),s2.c_str());
43227 }
43228 3603 }
43229 void FFScript::do_tracel(bool v)
43230 {
43231 int32_t temp = SH::get_arg(sarg1, v);
43232
43233 char tmp[32];
43234 sprintf(tmp, "%d\n", temp);
43235 TraceScriptIDs();
43236 al_trace("%s", tmp);
43237 if (replay_is_active() && replay_get_meta_bool("script_trace"))
43238 replay_step_comment(fmt::format("trace: {}", temp));
43239
43240 if ( zscript_debugger )
43241 {
43242 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
43243 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),tmp);
43244 }
43245 }
43246
43247 void FFScript::do_tracebool(const bool v)
43248 {
43249 int32_t temp = SH::get_arg(sarg1, v);
43250 TraceScriptIDs();
43251 char const* str = temp ? "true\n" : "false\n";
43252 al_trace("%s", str);
43253 if (replay_is_active() && replay_get_meta_bool("script_trace"))
43254 replay_step_comment(fmt::format("trace: {}", (bool)temp));
43255
43256 if ( zscript_debugger )
43257 {
43258 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
43259 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),str);
43260 }
43261 }
43262
43263 3993 void traceStr(string const& str)
43264 {
43265 3993 FFCore.TraceScriptIDs();
43266 3993 safe_al_trace(str);
43267
7/16
✗ Branch 0 not taken.
✓ Branch 1 taken 3993 times.
✓ Branch 2 taken 3993 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3993 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3993 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3993 times.
✓ Branch 10 taken 671 times.
✓ Branch 11 taken 3322 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
7986 if (replay_is_active() && replay_get_meta_bool("script_trace"))
43268
1/2
✓ Branch 0 taken 3322 times.
✗ Branch 1 not taken.
3322 replay_step_comment("trace: " + str);
43269
43270
1/2
✓ Branch 0 taken 3993 times.
✗ Branch 1 not taken.
3993 if ( zscript_debugger )
43271 {
43272 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
43273 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),str.c_str());
43274 }
43275 3993 }
43276
43277 384 void FFScript::do_tracestring()
43278 {
43279 384 int32_t arrayptr = get_register(sarg1) / 10000;
43280 384 string str;
43281
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 ArrayH::getString(arrayptr, str, 512);
43282
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 str += "\0"; //In the event that the user passed an array w/o NULL, don't crash.
43283
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 traceStr(str);
43284 384 }
43285
43286 bool is_valid_format(char c)
43287 {
43288 switch(c)
43289 {
43290 case 'f': case 'd': case 'i': case 'p':
43291 case 'l': case 's': case 'c': case 'X':
43292 case 'x': case 'b': case 'B': case 'a':
43293 return true;
43294 }
43295 return false;
43296 }
43297 28927 char const* zs_formatter(char const* format, int32_t arg, int32_t mindig)
43298 {
43299
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 28922 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
28927 static std::string ret;
43300
43301 28927 ret.clear();
43302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28927 times.
28927 if(format)
43303 {
43304 28927 char mindigbuf[8] = {0};
43305
2/2
✓ Branch 0 taken 27525 times.
✓ Branch 1 taken 1402 times.
28927 if(mindig)
43306 2804 sprintf(mindigbuf, "%%0%d%c", mindig,
43307
2/4
✓ Branch 0 taken 1402 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1402 times.
1402 (format[0] == 'x' || format[0] == 'X') ? format[0] : 'd');
43308 28927 bool tempbool = false;
43309
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 20603 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 8324 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
28927 switch(format[0])
43310 {
43311 case 'f':
43312 tempbool = true;
43313 [[fallthrough]];
43314 case 'd':
43315
2/2
✓ Branch 0 taken 20131 times.
✓ Branch 1 taken 472 times.
21075 if(arg%10000)
43316 472 tempbool = true;
43317 [[fallthrough]];
43318 case 'i':
43319 case 'p':
43320 {
43321 20603 char argbuf[32] = {0};
43322 20603 bool neg = arg < 0;
43323
2/2
✓ Branch 0 taken 1402 times.
✓ Branch 1 taken 19201 times.
20603 if(mindig)
43324 1402 sprintf(argbuf,mindigbuf,arg / 10000);
43325 19201 else zc_itoa(arg / 10000, argbuf);
43326
43327
2/2
✓ Branch 0 taken 20131 times.
✓ Branch 1 taken 472 times.
20603 if(tempbool) //add decimal places
43328 {
43329 472 arg = abs(arg);
43330 472 auto ind = strlen(argbuf);
43331 472 argbuf[ind++] = '.';
43332
2/2
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 472 times.
2360 for(int div = 1000; div > 0; div /= 10)
43333 1888 argbuf[ind++] = '0' + (arg/div)%10;
43334
4/4
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 244 times.
✓ Branch 3 taken 472 times.
716 for(--ind; argbuf[ind]=='0' && argbuf[ind-1]!='-'; --ind)
43335 {
43336 244 argbuf[ind] = 0;
43337 244 }
43338 472 }
43339
43340
4/4
✓ Branch 0 taken 929 times.
✓ Branch 1 taken 19674 times.
✓ Branch 2 taken 877 times.
✓ Branch 3 taken 52 times.
20603 if(neg && argbuf[0] != '-')
43341 52 ret = "-";
43342 20603 ret += argbuf;
43343 20603 return ret.c_str();
43344 }
43345 //
43346 case 'l':
43347 {
43348 char argbuf[32] = {0};
43349 if(mindig)
43350 sprintf(argbuf, mindigbuf, arg);
43351 else zc_itoa(arg, argbuf);
43352
43353 ret = argbuf;
43354 return ret.c_str();
43355 }
43356 //
43357 case 's':
43358 {
43359
1/2
✓ Branch 0 taken 8324 times.
✗ Branch 1 not taken.
8324 if(mindig)
43360 Z_scripterrlog("Cannot use minimum digits flag for '%%s'\n");
43361
1/2
✓ Branch 0 taken 8324 times.
✗ Branch 1 not taken.
8324 if(arg)
43362 {
43363 8324 int32_t strptr = (arg / 10000);
43364 8324 ArrayManager am(strptr);
43365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8324 times.
8324 if(am.invalid())
43366 ret = "<INVALID STRING>";
43367 8324 else ArrayH::getString(strptr, ret, MAX_ZC_ARRAY_SIZE);
43368 8324 }
43369 else ret = "<NULL>";
43370 8324 return ret.c_str();
43371 }
43372 case 'c':
43373 {
43374 if(mindig)
43375 Z_scripterrlog("Cannot use minimum digits flag for '%%c'\n");
43376 int32_t c = (arg / 10000);
43377 if ( (char(c)) != c )
43378 {
43379 Z_scripterrlog("Illegal char value (%d) passed to sprintf as '%%c' arg\n", c);
43380 Z_scripterrlog("Value of invalid char will overflow.\n");
43381 }
43382 ret.push_back(char(c));
43383 return ret.c_str();
43384 }
43385 //
43386 case 'X':
43387 tempbool = true;
43388 [[fallthrough]];
43389 case 'x':
43390 {
43391 char argbuf[32] = {0};
43392 if(mindig)
43393 sprintf(argbuf,mindigbuf,arg / 10000);
43394 else zc_itoa( (arg/10000), argbuf, 16 ); //base 16; hex
43395
43396 for ( int32_t inx = 0; inx < 16; ++inx ) //set chosen caps
43397 {
43398 argbuf[inx] = ( tempbool ? toupper(argbuf[inx]) : tolower(argbuf[inx]) );
43399 }
43400 ret = "0x";
43401 ret += argbuf;
43402 return ret.c_str();
43403 }
43404 //
43405 case 'b': //int binary
43406 arg /= 10000;
43407 [[fallthrough]];
43408 case 'B': //long binary
43409 {
43410 char argbuf[33] = {0};
43411 int num_digits = mindig;
43412 for(int q = num_digits; q < 32; ++q)
43413 if(arg&(1<<q))
43414 num_digits = q+1;
43415 for(int q = 0; q < num_digits; ++q)
43416 {
43417 argbuf[q] = (arg&(1<<(num_digits-q-1)))
43418 ? '1' : '0';
43419 }
43420 ret = argbuf;
43421 return ret.c_str();
43422 }
43423 case 'a': //array
43424 {
43425 if(arg)
43426 {
43427 if(!is_valid_format(format[1]))
43428 {
43429 Z_scripterrlog("Format '%%a%c' is invalid!\n",format[1]);
43430 break;
43431 }
43432 ArrayManager am(arg/10000);
43433 ret = am.asString([&](int32_t val)
43434 {
43435 return zs_formatter(format+1, val, mindig);
43436 }, 214748);
43437 }
43438 else ret = "{ NULL }";
43439 return ret.c_str();
43440 }
43441 default:
43442 {
43443 Z_scripterrlog("Error: '%%%c' is not a valid printf argument.\n",format[0]);
43444 return ret.c_str();
43445 }
43446 }
43447 }
43448 Z_scripterrlog("Error: No format parameter given for zs_formatter\n");
43449 return ret.c_str();
43450 28927 }
43451
43452 15254 string zs_sprintf(char const* format, int32_t num_args, const bool varg)
43453 {
43454 15254 int32_t arg_offset = ((ri->sp + num_args) - 1);
43455 15254 int32_t next_arg = 0;
43456 15254 bool is_old_args = get_qr(qr_OLD_PRINTF_ARGS);
43457 15254 ostringstream oss;
43458
2/2
✓ Branch 0 taken 11618 times.
✓ Branch 1 taken 32563 times.
44181 while(format[0] != '\0')
43459 {
43460 32563 int32_t arg_val = 0;
43461
2/2
✓ Branch 0 taken 3636 times.
✓ Branch 1 taken 28927 times.
32563 if(next_arg < num_args)
43462 {
43463
2/2
✓ Branch 0 taken 5379 times.
✓ Branch 1 taken 23548 times.
28927 if(varg)
43464
1/2
✓ Branch 0 taken 5379 times.
✗ Branch 1 not taken.
5379 arg_val = zs_vargs.at(next_arg);
43465 else
43466
1/2
✓ Branch 0 taken 23548 times.
✗ Branch 1 not taken.
23548 arg_val = SH::read_stack(arg_offset - next_arg);
43467 28927 }
43468 32563 char buf[256] = {0};
43469
2/2
✓ Branch 0 taken 28927 times.
✓ Branch 1 taken 87960 times.
116887 for ( int32_t q = 0; q < 256; ++q )
43470 {
43471
2/2
✓ Branch 0 taken 3636 times.
✓ Branch 1 taken 84324 times.
87960 if(format[0] == '\0') //done
43472 {
43473
1/2
✓ Branch 0 taken 3636 times.
✗ Branch 1 not taken.
3636 oss << buf;
43474
1/2
✓ Branch 0 taken 3636 times.
✗ Branch 1 not taken.
3636 return oss.str();
43475 }
43476
2/2
✓ Branch 0 taken 29242 times.
✓ Branch 1 taken 55082 times.
84324 else if(format[0] == '%')
43477 {
43478 29242 ++format;
43479 29242 int32_t min_digits = 0;
43480
3/4
✓ Branch 0 taken 1402 times.
✓ Branch 1 taken 27840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1402 times.
29242 if(format[0] == '0' && !is_old_args)
43481 {
43482 1402 char argbuf[4] = {0};
43483 1402 int32_t q = 0;
43484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2804 times.
2804 while(q < 4)
43485 {
43486 2804 ++format;
43487 2804 char c = format[0];
43488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2804 times.
2804 if(c == '\0')
43489 {
43490 Z_scripterrlog("Cannot use minimum digits flag with no argument\n");
43491 oss << buf;
43492 return oss.str();
43493 }
43494
3/4
✓ Branch 0 taken 2804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1402 times.
✓ Branch 3 taken 1402 times.
2804 if(c >= '0' && c <= '9')
43495 1402 argbuf[q++] = c;
43496 else
43497 {
43498 1402 --format;
43499 1402 break;
43500 }
43501 }
43502 1402 ++format;
43503 1402 min_digits = atoi(argbuf);
43504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1402 times.
1402 if(!min_digits)
43505 {
43506 Z_scripterrlog("Error formatting string: Invalid number '%s'\n", argbuf);
43507 }
43508 1402 }
43509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29242 times.
29242 bool bin = (format[0] == 'b' || format[0] == 'B');
43510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29242 times.
29242 bool hex = (format[0] == 'x' || format[0] == 'X');
43511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29242 times.
29242 if(bin)
43512 {
43513 if(min_digits > 32)
43514 {
43515 Z_scripterrlog("Min digits argument cannot be larger than 32!"
43516 " Value will be truncated to 32.");
43517 min_digits = 32;
43518 }
43519 }
43520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29242 times.
29242 else if(min_digits > 10)
43521 {
43522 Z_scripterrlog("Min digits argument cannot be larger than 10!"
43523 " Value will be truncated to 10.");
43524 min_digits = 10;
43525 }
43526 29242 char mindigbuf[15] = {0};
43527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29242 times.
29242 sprintf(mindigbuf, "%%0%d%c", min_digits, hex ? format[0] : 'd');
43528 29242 bool tempbool = false;
43529
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 28927 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 315 times.
29242 switch( format[0] )
43530 {
43531 case 'd':
43532 case 'f':
43533 case 'i': case 'p':
43534 case 'l':
43535 case 's':
43536 case 'c':
43537 case 'x': case 'X':
43538 case 'b': case 'B':
43539 {
43540 28927 ++next_arg;
43541
3/6
✓ Branch 0 taken 28927 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28927 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 28927 times.
✗ Branch 5 not taken.
28927 oss << buf << zs_formatter(format,arg_val,min_digits);
43542 28927 q = 300; //break main loop
43543 28927 break;
43544 }
43545 case 'a': //array print
43546 {
43547 ++next_arg;
43548 oss << buf << zs_formatter(format,arg_val,min_digits);
43549 while(format[0] == 'a')
43550 {
43551 if(is_valid_format(format[1]))
43552 ++format;
43553 else break;
43554 }
43555 q = 300; //break main loop
43556 break;
43557 }
43558 case '%':
43559 {
43560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 if(min_digits)
43561 Z_scripterrlog("Cannot use minimum digits flag for '%%%%'\n");
43562 315 buf[q] = '%';
43563 315 break;
43564 }
43565 default:
43566 {
43567 if(is_old_args)
43568 buf[q] = format[0];
43569 else
43570 {
43571 Z_scripterrlog("Error: '%%%c' is not a valid printf argument.\n",format[0]);
43572 }
43573 break;
43574 }
43575 }
43576 29242 ++format;
43577 29242 }
43578 else
43579 {
43580 55082 buf[q] = format[0];
43581 55082 ++format;
43582 }
43583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84324 times.
84324 if(q == 255)
43584 {
43585 oss << buf;
43586 break;
43587 }
43588 84324 }
43589 }
43590
1/2
✓ Branch 0 taken 11618 times.
✗ Branch 1 not taken.
11618 return oss.str();
43591 15254 }
43592
43593 3609 void FFScript::do_printf(const bool v, const bool varg)
43594 {
43595 int32_t num_args, format_arrayptr;
43596
2/2
✓ Branch 0 taken 3322 times.
✓ Branch 1 taken 287 times.
3609 if(varg)
43597 {
43598 3322 num_args = zs_vargs.size();
43599 3322 format_arrayptr = SH::read_stack(ri->sp) / 10000;
43600 3322 }
43601 else
43602 {
43603 287 num_args = SH::get_arg(sarg1, v) / 10000;
43604 287 format_arrayptr = SH::read_stack(ri->sp + num_args) / 10000;
43605 }
43606 3609 string formatstr;
43607
1/2
✓ Branch 0 taken 3609 times.
✗ Branch 1 not taken.
3609 ArrayH::getString(format_arrayptr, formatstr, MAX_ZC_ARRAY_SIZE);
43608
43609
2/4
✓ Branch 0 taken 3609 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3609 times.
3609 traceStr(zs_sprintf(formatstr.c_str(), num_args, varg));
43610
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 3322 times.
3609 if(varg) zs_vargs.clear();
43611 3609 }
43612 11645 void FFScript::do_sprintf(const bool v, const bool varg)
43613 {
43614 int32_t num_args, dest_arrayptr, format_arrayptr;
43615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11645 times.
11645 if(varg)
43616 {
43617 num_args = zs_vargs.size();
43618 dest_arrayptr = SH::read_stack(ri->sp + 1) / 10000;
43619 format_arrayptr = SH::read_stack(ri->sp) / 10000;
43620 }
43621 else
43622 {
43623 11645 num_args = SH::get_arg(sarg1, v) / 10000;
43624 11645 dest_arrayptr = SH::read_stack(ri->sp + num_args + 1) / 10000;
43625 11645 format_arrayptr = SH::read_stack(ri->sp + num_args) / 10000;
43626 }
43627 11645 string formatstr;
43628
1/2
✓ Branch 0 taken 11645 times.
✗ Branch 1 not taken.
11645 ArrayH::getString(format_arrayptr, formatstr, MAX_ZC_ARRAY_SIZE);
43629
43630
1/2
✓ Branch 0 taken 11645 times.
✗ Branch 1 not taken.
11645 string output = zs_sprintf(formatstr.c_str(), num_args, varg);
43631
2/4
✓ Branch 0 taken 11645 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11645 times.
11645 if(ArrayH::setArray(dest_arrayptr, output) == SH::_Overflow)
43632 {
43633 Z_scripterrlog("Dest string supplied to 'sprintf()' not large enough\n");
43634 ri->d[rEXP1] = ArrayH::strlen(dest_arrayptr);
43635 }
43636 11645 else ri->d[rEXP1] = output.size();
43637
1/2
✓ Branch 0 taken 11645 times.
✗ Branch 1 not taken.
11645 if(varg) zs_vargs.clear();
43638 11645 }
43639 25969 void FFScript::do_varg_max()
43640 {
43641 25969 int32_t num_args = zs_vargs.size();
43642 25969 int32_t val = 0;
43643
1/2
✓ Branch 0 taken 25969 times.
✗ Branch 1 not taken.
25969 if (num_args > 0)
43644 25969 val = zs_vargs.at(0);
43645
2/2
✓ Branch 0 taken 25969 times.
✓ Branch 1 taken 25969 times.
51938 for(auto q = 1; q < num_args; ++q)
43646 {
43647 25969 int32_t tval = zs_vargs.at(q);
43648
2/2
✓ Branch 0 taken 7998 times.
✓ Branch 1 taken 17971 times.
25969 if(tval > val) val = tval;
43649 25969 }
43650 25969 zs_vargs.clear();
43651 25969 ri->d[rEXP1] = val;
43652 25969 }
43653 71 void FFScript::do_varg_min()
43654 {
43655 71 int32_t num_args = zs_vargs.size();
43656 71 int32_t val = 0;
43657
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 if (num_args > 0)
43658 71 val = zs_vargs.at(0);
43659
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 71 times.
142 for(auto q = 1; q < num_args; ++q)
43660 {
43661 71 int32_t tval = zs_vargs.at(q);
43662
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 if(tval < val) val = tval;
43663 71 }
43664 71 zs_vargs.clear();
43665 71 ri->d[rEXP1] = val;
43666 71 }
43667 void FFScript::do_varg_choose()
43668 {
43669 int32_t num_args = zs_vargs.size();
43670 int32_t val = 0;
43671 if(num_args > 0)
43672 {
43673 int32_t choice = zc_rand(num_args-1);
43674 val = zs_vargs.at(choice);
43675 }
43676 zs_vargs.clear();
43677 ri->d[rEXP1] = val;
43678 }
43679
43680 void FFScript::do_breakpoint()
43681 {
43682 int32_t arrayptr = get_register(sarg1) / 10000;
43683 string str;
43684 if(arrayptr && sarg1 != NUL)
43685 {
43686 ArrayH::getString(arrayptr, str, 512);
43687 str = "Breakpoint: " + str + "\n";
43688 }
43689 else str = "Breakpoint\n";
43690 TraceScriptIDs();
43691 al_trace("%s", str.c_str());
43692
43693 if ( zscript_debugger )
43694 {
43695 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_RED |
43696 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),str.c_str());
43697 }
43698 if( zasm_debugger )
43699 {
43700 FFCore.zasm_break_mode = ZASM_BREAK_HALT; //Halt ZASM debugger; break execution
43701 coloured_console.safeprint((CConsoleLoggerEx::COLOR_RED |
43702 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),str.c_str());
43703 }
43704 }
43705
43706 void FFScript::do_tracenl()
43707 {
43708 safe_al_trace("\n");
43709
43710 if ( zscript_debugger )
43711 {
43712 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
43713 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),"\n");
43714 }
43715 }
43716
43717
43718 36998 void FFScript::TraceScriptIDs(bool zasm_console)
43719 {
43720 if(DEVTIMESTAMP)
43721 {
43722 if(!zasm_debugger && zasm_console) return;
43723 CConsoleLoggerEx console = (zasm_console ? coloured_console : zscript_coloured_console);
43724 bool cond = (zasm_console ? zasm_debugger : zscript_debugger);
43725
43726 char buf[256] = {0};
43727 //Calculate timestamp
43728 struct tm * tm_struct;
43729 time_t sysRTC;
43730 time (&sysRTC);
43731 tm_struct = localtime (&sysRTC);
43732
43733 sprintf(buf, "[%d:%d:%d] ", tm_struct->tm_hour, tm_struct->tm_min, tm_struct->tm_sec);
43734 //
43735
43736 al_trace("%s", buf);
43737 if ( cond ) {console.safeprint((CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
43738 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),buf); }
43739 }
43740
2/2
✓ Branch 0 taken 33593 times.
✓ Branch 1 taken 3405 times.
36998 if(get_qr(qr_TRACESCRIPTIDS) || DEVLOGGING )
43741 {
43742
2/4
✓ Branch 0 taken 3405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3405 times.
✗ Branch 3 not taken.
3405 if(!zasm_debugger && zasm_console) return;
43743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3405 times.
3405 CConsoleLoggerEx console = (zasm_console ? coloured_console : zscript_coloured_console);
43744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3405 times.
3405 bool cond = (zasm_console ? zasm_debugger : zscript_debugger);
43745 3405 char buf[256] = {0};
43746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3405 times.
3405 if(script_funcrun)
43747 {
43748 sprintf(buf, "Destructor(%d,%s): ", ri->thiskey, destructstr?destructstr->c_str():"UNKNOWN");
43749 }
43750
4/17
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1297 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2058 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
3405 else switch(curScriptType)
43751 {
43752 case ScriptType::Global:
43753 {
43754 switch(curScriptNum)
43755 {
43756 case GLOBAL_SCRIPT_INIT:
43757 sprintf(buf, "Global Init(%s): ", globalmap[curScriptNum].scriptname.c_str());
43758 break;
43759 case GLOBAL_SCRIPT_GAME:
43760 sprintf(buf, "Global Active(%s): ", globalmap[curScriptNum].scriptname.c_str());
43761 break;
43762 case GLOBAL_SCRIPT_END:
43763 sprintf(buf, "Global Exit(%s): ", globalmap[curScriptNum].scriptname.c_str());
43764 break;
43765 case GLOBAL_SCRIPT_ONSAVELOAD:
43766 sprintf(buf, "Global SaveLoad(%s): ", globalmap[curScriptNum].scriptname.c_str());
43767 break;
43768 case GLOBAL_SCRIPT_ONLAUNCH:
43769 sprintf(buf, "Global Launch(%s): ", globalmap[curScriptNum].scriptname.c_str());
43770 break;
43771 case GLOBAL_SCRIPT_ONCONTGAME:
43772 sprintf(buf, "Global ContGame(%s): ", globalmap[curScriptNum].scriptname.c_str());
43773 break;
43774 case GLOBAL_SCRIPT_F6:
43775 sprintf(buf, "Global F6Menu(%s): ", globalmap[curScriptNum].scriptname.c_str());
43776 break;
43777 case GLOBAL_SCRIPT_ONSAVE:
43778 sprintf(buf, "Global Save(%s): ", globalmap[curScriptNum].scriptname.c_str());
43779 break;
43780 }
43781 break;
43782 }
43783
43784 case ScriptType::Player:
43785 {
43786 switch(curScriptNum)
43787 {
43788 case SCRIPT_PLAYER_INIT:
43789 sprintf(buf, "Player Init(%s): ", playermap[curScriptNum-1].scriptname.c_str());
43790 break;
43791 case SCRIPT_PLAYER_ACTIVE:
43792 sprintf(buf, "Player Active(%s): ", playermap[curScriptNum-1].scriptname.c_str());
43793 break;
43794 case SCRIPT_PLAYER_DEATH:
43795 sprintf(buf, "Player Death(%s): ", playermap[curScriptNum-1].scriptname.c_str());
43796 break;
43797 case SCRIPT_PLAYER_WIN:
43798 sprintf(buf, "Player Win(%s): ", playermap[curScriptNum-1].scriptname.c_str());
43799 break;
43800 }
43801 break;
43802 }
43803
43804 case ScriptType::Lwpn:
43805
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 sprintf(buf, "LWeapon(%u, %s): ", curScriptNum,lwpnmap[curScriptNum-1].scriptname.c_str());
43806 48 break;
43807
43808 case ScriptType::Ewpn:
43809 sprintf(buf, "EWeapon(%u, %s): ", curScriptNum,ewpnmap[curScriptNum-1].scriptname.c_str());
43810 break;
43811
43812 case ScriptType::NPC:
43813 sprintf(buf, "NPC(%u, %s): ", curScriptNum,npcmap[curScriptNum-1].scriptname.c_str());
43814 break;
43815
43816 case ScriptType::FFC:
43817
1/2
✓ Branch 0 taken 1297 times.
✗ Branch 1 not taken.
1297 sprintf(buf, "FFC(%u, %s): ", curScriptNum,ffcmap[curScriptNum-1].scriptname.c_str());
43818 1297 break;
43819
43820 case ScriptType::Item:
43821 sprintf(buf, "Item(%u, %s): ", curScriptNum,itemmap[curScriptNum-1].scriptname.c_str());
43822 break;
43823
43824 case ScriptType::OnMap:
43825 sprintf(buf, "DMapMap(%u, %s): ", curScriptNum,dmapmap[curScriptNum-1].scriptname.c_str());
43826 break;
43827 case ScriptType::ActiveSubscreen:
43828 sprintf(buf, "DMapASub(%u, %s): ", curScriptNum,dmapmap[curScriptNum-1].scriptname.c_str());
43829 break;
43830 case ScriptType::PassiveSubscreen:
43831
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 sprintf(buf, "DMapPSub(%u, %s): ", curScriptNum,dmapmap[curScriptNum-1].scriptname.c_str());
43832 2 break;
43833 case ScriptType::DMap:
43834
1/2
✓ Branch 0 taken 2058 times.
✗ Branch 1 not taken.
2058 sprintf(buf, "DMap(%u, %s): ", curScriptNum,dmapmap[curScriptNum-1].scriptname.c_str());
43835 2058 break;
43836
43837 case ScriptType::ItemSprite:
43838 sprintf(buf, "ItemSprite(%u, %s): ", curScriptNum,itemspritemap[curScriptNum-1].scriptname.c_str());
43839 break;
43840
43841 case ScriptType::Screen:
43842 sprintf(buf, "Screen(%u, %s): ", curScriptNum,screenmap[curScriptNum-1].scriptname.c_str());
43843 break;
43844
43845 case ScriptType::Combo:
43846 sprintf(buf, "Combo(%u, %s): ", curScriptNum,comboscriptmap[curScriptNum-1].scriptname.c_str());
43847 break;
43848
43849 case ScriptType::Generic:
43850 sprintf(buf, "Generic(%u, %s): ", curScriptNum,genericmap[curScriptNum-1].scriptname.c_str());
43851 break;
43852
43853 case ScriptType::GenericFrozen:
43854 sprintf(buf, "GenericFRZ(%u, %s): ", curScriptNum,genericmap[curScriptNum-1].scriptname.c_str());
43855 break;
43856 }
43857
43858
1/2
✓ Branch 0 taken 3405 times.
✗ Branch 1 not taken.
3405 al_trace("%s", buf);
43859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3405 times.
3405 if ( cond )
43860 console.safeprint((CConsoleLoggerEx::COLOR_GREEN|CConsoleLoggerEx::COLOR_INTENSITY|
43861 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),buf);
43862 3405 }
43863 36998 }
43864
43865 2 void FFScript::do_cleartrace()
43866 {
43867 2 zc_trace_clear();
43868 2 clearConsole();
43869 2 }
43870
43871 1 string inttobase(word base, int32_t x, word mindigits)
43872 {
43873 static const char coeff[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
43874
43875 1 string s2;
43876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 word digits = zc_max(mindigits - 1, word(floor(log(double(x)) / log(double(base)))));
43877
43878
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 for(int32_t i = digits; i >= 0; i--)
43879 {
43880
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 s2 += coeff[word(floor(x / pow(double(base), i))) % base];
43881 1 }
43882
43883 1 return s2;
43884
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 }
43885
43886 1 void FFScript::do_tracetobase()
43887 {
43888 1 int32_t x = SH::read_stack(ri->sp + 2) / 10000;
43889 1 uint32_t base = vbound(SH::read_stack(ri->sp + 1) / 10000, 2, 36);
43890
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 uint32_t mindigits = zc_max(1, SH::read_stack(ri->sp) / 10000);
43891
43892
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 string s2 = x < 0 ? "-": "";
43893
43894
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 switch(base)
43895 {
43896 case 8:
43897 s2 += '0';
43898 break;
43899
43900 case 16:
43901 s2 += "0x";
43902 break;
43903 }
43904
43905
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 s2 += inttobase(base, int32_t(fabs(double(x))), mindigits);
43906
43907
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 switch(base)
43908 {
43909 case 8:
43910 case 10:
43911 case 16:
43912 1 break;
43913
43914 case 2:
43915 s2 += 'b';
43916 break;
43917
43918 default:
43919 std::stringstream ss;
43920 ss << " (Base " << base << ')';
43921 s2 += ss.str();
43922 break;
43923 }
43924
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 TraceScriptIDs();
43925
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 s2 += "\n";
43926
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 al_trace("%s", s2.c_str());
43927
43928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( zscript_debugger )
43929 {
43930 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
43931 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),s2.c_str());
43932 }
43933 1 }
43934
43935 //SRAM Functions
43936 void FFScript::write_dmaps(PACKFILE *f, int32_t vers_id)
43937 {
43938 word dmap_count=count_dmaps();
43939
43940 dmap_count=zc_min(dmap_count, 512);
43941 dmap_count=zc_min(dmap_count, MAXDMAPS-0);
43942
43943 //finally... section data
43944 if(!p_iputw(dmap_count,f))
43945 {
43946 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",5);
43947 }
43948
43949
43950 for(int32_t i=0; i<dmap_count; i++)
43951 {
43952 if(!p_putc(DMaps[i].map,f))
43953 {
43954 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",6);
43955 }
43956
43957 if(!p_iputw(DMaps[i].level,f))
43958 {
43959 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",7);
43960 }
43961
43962 if(!p_putc(DMaps[i].xoff,f))
43963 {
43964 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",8);
43965 }
43966
43967 if(!p_putc(DMaps[i].compass,f))
43968 {
43969 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",9);
43970 }
43971
43972 if(!p_iputw(DMaps[i].color,f))
43973 {
43974 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",10);
43975 }
43976
43977 if(!p_putc(DMaps[i].midi,f))
43978 {
43979 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",11);
43980 }
43981
43982 if(!p_putc(DMaps[i].cont,f))
43983 {
43984 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",12);
43985 }
43986
43987 if(!p_putc(DMaps[i].type,f))
43988 {
43989 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",13);
43990 }
43991
43992 for(int32_t j=0; j<8; j++)
43993 {
43994 if(!p_putc(DMaps[i].grid[j],f))
43995 {
43996 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",14);
43997 }
43998 }
43999
44000 //16
44001 if(!pfwrite(&DMaps[i].name,sizeof(DMaps[0].name),f))
44002 {
44003 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",15);
44004 }
44005
44006 if(!pfwrite(&DMaps[i].title,sizeof(DMaps[0].title),f))
44007 {
44008 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",16);
44009 }
44010
44011 if(!pfwrite(&DMaps[i].intro,sizeof(DMaps[0].intro),f))
44012 {
44013 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",17);
44014 }
44015
44016 if(!p_iputl(DMaps[i].minimap_1_tile,f))
44017 {
44018 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",18);
44019 }
44020
44021 if(!p_putc(DMaps[i].minimap_1_cset,f))
44022 {
44023 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",19);
44024 }
44025
44026 if(!p_iputl(DMaps[i].minimap_2_tile,f))
44027 {
44028 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",20);
44029 }
44030
44031 if(!p_putc(DMaps[i].minimap_2_cset,f))
44032 {
44033 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",21);
44034 }
44035
44036 if(!p_iputl(DMaps[i].largemap_1_tile,f))
44037 {
44038 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",22);
44039 }
44040
44041 if(!p_putc(DMaps[i].largemap_1_cset,f))
44042 {
44043 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",23);
44044 }
44045
44046 if(!p_iputl(DMaps[i].largemap_2_tile,f))
44047 {
44048 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",24);
44049 }
44050
44051 if(!p_putc(DMaps[i].largemap_2_cset,f))
44052 {
44053 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",25);
44054 }
44055
44056 if(!pfwrite(&DMaps[i].tmusic,sizeof(DMaps[0].tmusic),f))
44057 {
44058 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",26);
44059 }
44060
44061 if(!p_putc(DMaps[i].tmusictrack,f))
44062 {
44063 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",25);
44064 }
44065
44066 if(!p_putc(DMaps[i].active_subscreen,f))
44067 {
44068 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",26);
44069 }
44070
44071 if(!p_putc(DMaps[i].passive_subscreen,f))
44072 {
44073 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",27);
44074 }
44075
44076 byte disabled[32];
44077 memset(disabled,0,32);
44078
44079 for(int32_t j=0; j<MAXITEMS; j++)
44080 {
44081 if(DMaps[i].disableditems[j])
44082 {
44083 disabled[j/8] |= (1 << (j%8));
44084 }
44085 }
44086
44087 if(!pfwrite(disabled,32,f))
44088 {
44089 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",28);
44090 }
44091
44092 if(!p_iputl(DMaps[i].flags,f))
44093 {
44094 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",29);
44095 }
44096 if(!p_putc(DMaps[i].sideview,f))
44097 {
44098 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",30);
44099 }
44100 if(!p_iputw(DMaps[i].script,f))
44101 {
44102 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",31);
44103 }
44104 for ( int32_t q = 0; q < 8; q++ )
44105 {
44106 if(!p_iputl(DMaps[i].initD[q],f))
44107 {
44108 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",32);
44109 }
44110
44111 }
44112 for ( int32_t q = 0; q < 8; q++ )
44113 {
44114 for ( int32_t w = 0; w < 65; w++ )
44115 {
44116 if (!p_putc(DMaps[i].initD_label[q][w],f))
44117 {
44118 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",33);
44119 }
44120 }
44121 }
44122 }
44123 }
44124 void FFScript::read_dmaps(PACKFILE *f, int32_t vers_id)
44125 {
44126 word dmap_count=count_dmaps();
44127
44128 dmap_count=zc_min(dmap_count, 512);
44129 dmap_count=zc_min(dmap_count, MAXDMAPS-0);
44130
44131 //finally... section data
44132 if(!p_igetw(&dmap_count,f))
44133 {
44134 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",5);
44135 }
44136
44137
44138 for(int32_t i=0; i<dmap_count; i++)
44139 {
44140 if(!p_getc(&DMaps[i].map,f))
44141 {
44142 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",6);
44143 }
44144
44145 if(!p_igetw(&DMaps[i].level,f))
44146 {
44147 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",7);
44148 }
44149
44150 if(!p_getc(&DMaps[i].xoff,f))
44151 {
44152 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",8);
44153 }
44154
44155 if(!p_getc(&DMaps[i].compass,f))
44156 {
44157 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",9);
44158 }
44159
44160 if(!p_igetw(&DMaps[i].color,f))
44161 {
44162 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",10);
44163 }
44164
44165 if(!p_getc(&DMaps[i].midi,f))
44166 {
44167 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",11);
44168 }
44169
44170 if(!p_getc(&DMaps[i].cont,f))
44171 {
44172 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",12);
44173 }
44174
44175 if(!p_getc(&DMaps[i].type,f))
44176 {
44177 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",13);
44178 }
44179
44180 for(int32_t j=0; j<8; j++)
44181 {
44182 if(!p_getc(&DMaps[i].grid[j],f))
44183 {
44184 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",14);
44185 }
44186 }
44187
44188 //16
44189 if(!pfread((&DMaps[i].name),sizeof(DMaps[0].name),f))
44190 {
44191 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",15);
44192 }
44193
44194 if(!pfread((&DMaps[i].title),sizeof(DMaps[0].title),f))
44195 {
44196 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",16);
44197 }
44198
44199 if(!pfread((&DMaps[i].intro),sizeof(DMaps[0].intro),f))
44200 {
44201 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",17);
44202 }
44203
44204 if(!p_igetl(&DMaps[i].minimap_1_tile,f))
44205 {
44206 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",18);
44207 }
44208
44209 if(!p_getc(&DMaps[i].minimap_1_cset,f))
44210 {
44211 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",19);
44212 }
44213
44214 if(!p_igetl(&DMaps[i].minimap_2_tile,f))
44215 {
44216 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",20);
44217 }
44218
44219 if(!p_getc(&DMaps[i].minimap_2_cset,f))
44220 {
44221 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",21);
44222 }
44223
44224 if(!p_igetl(&DMaps[i].largemap_1_tile,f))
44225 {
44226 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",22);
44227 }
44228
44229 if(!p_getc(&DMaps[i].largemap_1_cset,f))
44230 {
44231 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",23);
44232 }
44233
44234 if(!p_igetl(&DMaps[i].largemap_2_tile,f))
44235 {
44236 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",24);
44237 }
44238
44239 if(!p_getc(&DMaps[i].largemap_2_cset,f))
44240 {
44241 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",25);
44242 }
44243
44244 if(!pfread((&DMaps[i].tmusic),sizeof(DMaps[0].tmusic),f))
44245 {
44246 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",26);
44247 }
44248
44249 if(!p_getc(&DMaps[i].tmusictrack,f))
44250 {
44251 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",25);
44252 }
44253
44254 if(!p_getc(&DMaps[i].active_subscreen,f))
44255 {
44256 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",26);
44257 }
44258
44259 if(!p_getc(&DMaps[i].passive_subscreen,f))
44260 {
44261 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",27);
44262 }
44263
44264 byte disabled[32];
44265 memset(disabled,0,32);
44266
44267 for(int32_t j=0; j<MAXITEMS; j++)
44268 {
44269 if(&DMaps[i].disableditems[j])
44270 {
44271 disabled[j/8] |= (1 << (j%8));
44272 }
44273 }
44274
44275 if(!pfread(disabled,32,f))
44276 {
44277 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",28);
44278 }
44279
44280 if(!p_igetl(&DMaps[i].flags,f))
44281 {
44282 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",29);
44283 }
44284 if(!p_getc(&DMaps[i].sideview,f))
44285 {
44286 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",30);
44287 }
44288 if(!p_igetw(&DMaps[i].script,f))
44289 {
44290 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",31);
44291 }
44292 for ( int32_t q = 0; q < 8; q++ )
44293 {
44294 if(!p_igetl(&DMaps[i].initD[q],f))
44295 {
44296 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",32);
44297 }
44298
44299 }
44300 for ( int32_t q = 0; q < 8; q++ )
44301 {
44302 for ( int32_t w = 0; w < 65; w++ )
44303 {
44304 if (!p_getc(&DMaps[i].initD_label[q][w],f))
44305 {
44306 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",33);
44307 }
44308 }
44309 }
44310 }
44311 }
44312
44313
44314
44315 void FFScript::read_combos(PACKFILE *f, int32_t version_id)
44316 {
44317
44318 word combos_used = 0;
44319
44320 if(!p_igetw(&combos_used,f))
44321 {
44322 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",5);
44323 }
44324
44325 for(int32_t i=0; i<combos_used; i++)
44326 {
44327 if(!p_igetl(&combobuf[i].tile,f))
44328 {
44329 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",6);
44330 }
44331
44332 if(!p_getc(&combobuf[i].flip,f))
44333 {
44334 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",7);
44335 }
44336
44337 if(!p_getc(&combobuf[i].walk,f))
44338 {
44339 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",8);
44340 }
44341
44342 if(!p_getc(&combobuf[i].type,f))
44343 {
44344 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",9);
44345 }
44346
44347 if(!p_getc(&combobuf[i].csets,f))
44348 {
44349 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",10);
44350 }
44351
44352 if(!p_getc(&combobuf[i].frames,f))
44353 {
44354 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",11);
44355 }
44356
44357 if(!p_getc(&combobuf[i].speed,f))
44358 {
44359 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",12);
44360 }
44361
44362 if(!p_igetw(&combobuf[i].nextcombo,f))
44363 {
44364 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",13);
44365 }
44366
44367 if(!p_getc(&combobuf[i].nextcset,f))
44368 {
44369 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",14);
44370 }
44371
44372 if(!p_getc(&combobuf[i].flag,f))
44373 {
44374 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",15);
44375 }
44376
44377 if(!p_getc(&combobuf[i].skipanim,f))
44378 {
44379 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",16);
44380 }
44381
44382 if(!p_igetw(&combobuf[i].nexttimer,f))
44383 {
44384 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",17);
44385 }
44386
44387 if(!p_getc(&combobuf[i].skipanimy,f))
44388 {
44389 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",18);
44390 }
44391
44392 if(!p_getc(&combobuf[i].animflags,f))
44393 {
44394 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",19);
44395 }
44396
44397 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
44398 {
44399 if(!p_igetl(&combobuf[i].attributes[q],f))
44400 {
44401 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",20);
44402 }
44403 }
44404 if(!p_igetl(&combobuf[i].usrflags,f))
44405 {
44406 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",21);
44407 }
44408 for ( int32_t q = 0; q < 6; q++ )
44409 {
44410 if(!p_igetl(&combobuf[i].triggerflags[q],f))
44411 {
44412 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",22);
44413 }
44414 }
44415
44416 if(!p_igetl(&combobuf[i].triggerlevel,f))
44417 {
44418 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",23);
44419 }
44420 for ( int32_t q = 0; q < 11; q++ )
44421 {
44422 if(!p_getc(&combobuf[i].label[q],f))
44423 {
44424 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",24);
44425 }
44426 }
44427 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
44428 {
44429 if(!p_getc(&combobuf[i].attribytes[q],f))
44430 {
44431 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",25);
44432 }
44433 }
44434 if(!p_igetw(&combobuf[i].script,f))
44435 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",26);
44436 for ( int32_t q = 0; q < 2; q++ )
44437 {
44438 if(!p_igetl(&combobuf[i].initd[q],f))
44439 {
44440 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",27);
44441 }
44442 }
44443 if(!p_igetl(&combobuf[i].o_tile,f))
44444 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",28);
44445 if(!p_getc(&combobuf[i].cur_frame,f))
44446 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",29);
44447 if(!p_getc(&combobuf[i].aclk,f))
44448 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",30);
44449 }
44450 }
44451
44452 void FFScript::write_combos(PACKFILE *f, int32_t version_id)
44453 {
44454
44455 word combos_used = 0;
44456
44457 //finally... section data
44458 combos_used=count_combos()-0;
44459 combos_used=zc_min(combos_used, MAXCOMBOS);
44460
44461 if(!p_iputw(combos_used,f))
44462 {
44463 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",5);
44464 }
44465
44466 for(int32_t i=0; i<combos_used; i++)
44467 {
44468 if(!p_iputl(combobuf[i].tile,f))
44469 {
44470 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",6);
44471 }
44472
44473 if(!p_putc(combobuf[i].flip,f))
44474 {
44475 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",7);
44476 }
44477
44478 if(!p_putc(combobuf[i].walk,f))
44479 {
44480 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",8);
44481 }
44482
44483 if(!p_putc(combobuf[i].type,f))
44484 {
44485 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",9);
44486 }
44487
44488 if(!p_putc(combobuf[i].csets,f))
44489 {
44490 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",10);
44491 }
44492
44493 if(!p_putc(combobuf[i].frames,f))
44494 {
44495 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",11);
44496 }
44497
44498 if(!p_putc(combobuf[i].speed,f))
44499 {
44500 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",12);
44501 }
44502
44503 if(!p_iputw(combobuf[i].nextcombo,f))
44504 {
44505 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",13);
44506 }
44507
44508 if(!p_putc(combobuf[i].nextcset,f))
44509 {
44510 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",14);
44511 }
44512
44513 if(!p_putc(combobuf[i].flag,f))
44514 {
44515 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",15);
44516 }
44517
44518 if(!p_putc(combobuf[i].skipanim,f))
44519 {
44520 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",16);
44521 }
44522
44523 if(!p_iputw(combobuf[i].nexttimer,f))
44524 {
44525 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",17);
44526 }
44527
44528 if(!p_putc(combobuf[i].skipanimy,f))
44529 {
44530 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",18);
44531 }
44532
44533 if(!p_putc(combobuf[i].animflags,f))
44534 {
44535 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",19);
44536 }
44537
44538 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
44539 {
44540 if(!p_iputl(combobuf[i].attributes[q],f))
44541 {
44542 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",20);
44543 }
44544 }
44545 if(!p_iputl(combobuf[i].usrflags,f))
44546 {
44547 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",21);
44548 }
44549 for ( int32_t q = 0; q < 6; q++ )
44550 {
44551 if(!p_iputl(combobuf[i].triggerflags[q],f))
44552 {
44553 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",22);
44554 }
44555 }
44556
44557 if(!p_iputl(combobuf[i].triggerlevel,f))
44558 {
44559 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",23);
44560 }
44561 for ( int32_t q = 0; q < 11; q++ )
44562 {
44563 if(!p_putc(combobuf[i].label[q],f))
44564 {
44565 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",24);
44566 }
44567 }
44568 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
44569 {
44570 if(!p_putc(combobuf[i].attribytes[q],f))
44571 {
44572 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",25);
44573 }
44574 }
44575 if(!p_iputw(combobuf[i].script,f))
44576 {
44577 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",26);
44578 }
44579 for ( int32_t q = 0; q < 2; q++ )
44580 {
44581 if(!p_iputl(combobuf[i].initd[q],f))
44582 {
44583 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",27);
44584 }
44585 }
44586 if(!p_iputl(combobuf[i].o_tile,f))
44587 {
44588 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",28);
44589 }
44590 if(!p_putc(combobuf[i].cur_frame,f))
44591 {
44592 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",29);
44593 }
44594 if(!p_putc(combobuf[i].aclk,f))
44595 {
44596 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",30);
44597 }
44598
44599 }
44600 }
44601 void FFScript::read_weaponsprtites(PACKFILE *f, int32_t vers_id)
44602 {
44603 for(int32_t i=0; i<MAXWPNS; i++)
44604 {
44605 word oldtile = 0;
44606 if(!p_igetw(&oldtile,f))
44607 {
44608 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",6);
44609 }
44610
44611 if(!p_getc(&wpnsbuf[i].misc,f))
44612 {
44613 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",7);
44614 }
44615
44616 if(!p_getc(&wpnsbuf[i].csets,f))
44617 {
44618 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",8);
44619 }
44620
44621 if(!p_getc(&wpnsbuf[i].frames,f))
44622 {
44623 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",9);
44624 }
44625
44626 if(!p_getc(&wpnsbuf[i].speed,f))
44627 {
44628 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",10);
44629 }
44630
44631 if(!p_getc(&wpnsbuf[i].type,f))
44632 {
44633 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",11);
44634 }
44635
44636 if(!p_igetw(&wpnsbuf[i].script,f))
44637 {
44638 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",12);
44639 }
44640
44641 if(!p_igetl(&wpnsbuf[i].tile,f))
44642 {
44643 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",12);
44644 }
44645 }
44646 }
44647 void FFScript::write_weaponsprtites(PACKFILE *f, int32_t vers_id)
44648 {
44649 for(int32_t i=0; i<MAXWPNS; i++)
44650 {
44651 if(!p_iputw(wpnsbuf[i].tile,f))
44652 {
44653 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",6);
44654 }
44655
44656 if(!p_putc(wpnsbuf[i].misc,f))
44657 {
44658 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",7);
44659 }
44660
44661 if(!p_putc(wpnsbuf[i].csets,f))
44662 {
44663 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",8);
44664 }
44665
44666 if(!p_putc(wpnsbuf[i].frames,f))
44667 {
44668 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",9);
44669 }
44670
44671 if(!p_putc(wpnsbuf[i].speed,f))
44672 {
44673 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",10);
44674 }
44675
44676 if(!p_putc(wpnsbuf[i].type,f))
44677 {
44678 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",11);
44679 }
44680
44681 if(!p_iputw(wpnsbuf[i].script,f))
44682 {
44683 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",12);
44684 }
44685
44686 if(!p_iputl(wpnsbuf[i].tile,f))
44687 {
44688 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",12);
44689 }
44690 }
44691 }
44692
44693
44694 void FFScript::read_enemies(PACKFILE *f, int32_t vers_id)
44695 {
44696 if ( !f ) return;
44697 for(int32_t i=0; i<MAXGUYS; i++)
44698 {
44699 if(!p_igetl(&guysbuf[i].flags,f))
44700 {
44701 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",6);
44702 }
44703
44704 if(!p_igetl(&guysbuf[i].flags2,f))
44705 {
44706 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",7);
44707 }
44708
44709 if(!p_igetl(&guysbuf[i].tile,f))
44710 {
44711 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",8);
44712 }
44713
44714 if(!p_getc(&guysbuf[i].width,f))
44715 {
44716 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",9);
44717 }
44718
44719 if(!p_getc(&guysbuf[i].height,f))
44720 {
44721 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",10);
44722 }
44723
44724 if(!p_igetl(&guysbuf[i].s_tile,f))
44725 {
44726 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",11);
44727 }
44728
44729 if(!p_getc(&guysbuf[i].s_width,f))
44730 {
44731 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",12);
44732 }
44733
44734 if(!p_getc(&guysbuf[i].s_height,f))
44735 {
44736 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",13);
44737 }
44738
44739 if(!p_igetl(&guysbuf[i].e_tile,f))
44740 {
44741 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",14);
44742 }
44743
44744 if(!p_getc(&guysbuf[i].e_width,f))
44745 {
44746 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",15);
44747 }
44748
44749 if(!p_getc(&guysbuf[i].e_height,f))
44750 {
44751 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",16);
44752 }
44753
44754 if(!p_igetw(&guysbuf[i].hp,f))
44755 {
44756 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",17);
44757 }
44758
44759 if(!p_igetw(&guysbuf[i].family,f))
44760 {
44761 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",18);
44762 }
44763
44764 if(!p_igetw(&guysbuf[i].cset,f))
44765 {
44766 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",19);
44767 }
44768
44769 if(!p_igetw(&guysbuf[i].anim,f))
44770 {
44771 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",20);
44772 }
44773
44774 if(!p_igetw(&guysbuf[i].e_anim,f))
44775 {
44776 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",21);
44777 }
44778
44779 if(!p_igetw(&guysbuf[i].frate,f))
44780 {
44781 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",22);
44782 }
44783
44784 if(!p_igetw(&guysbuf[i].e_frate,f))
44785 {
44786 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",23);
44787 }
44788
44789 if(!p_igetw(&guysbuf[i].dp,f))
44790 {
44791 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",24);
44792 }
44793
44794 if(!p_igetw(&guysbuf[i].wdp,f))
44795 {
44796 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",25);
44797 }
44798
44799 if(!p_igetw(&guysbuf[i].weapon,f))
44800 {
44801 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",26);
44802 }
44803
44804 if(!p_igetw(&guysbuf[i].rate,f))
44805 {
44806 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",27);
44807 }
44808
44809 if(!p_igetw(&guysbuf[i].hrate,f))
44810 {
44811 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",28);
44812 }
44813
44814 if(!p_igetw(&guysbuf[i].step,f))
44815 {
44816 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",29);
44817 }
44818
44819 if(!p_igetw(&guysbuf[i].homing,f))
44820 {
44821 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",30);
44822 }
44823
44824 if(!p_igetw(&guysbuf[i].grumble,f))
44825 {
44826 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",31);
44827 }
44828
44829 if(!p_igetw(&guysbuf[i].item_set,f))
44830 {
44831 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",32);
44832 }
44833
44834 if(!p_igetl(&guysbuf[i].misc1,f))
44835 {
44836 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",33);
44837 }
44838
44839 if(!p_igetl(&guysbuf[i].misc2,f))
44840 {
44841 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",34);
44842 }
44843
44844 if(!p_igetl(&guysbuf[i].misc3,f))
44845 {
44846 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",35);
44847 }
44848
44849 if(!p_igetl(&guysbuf[i].misc4,f))
44850 {
44851 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",36);
44852 }
44853
44854 if(!p_igetl(&guysbuf[i].misc5,f))
44855 {
44856 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",37);
44857 }
44858
44859 if(!p_igetl(&guysbuf[i].misc6,f))
44860 {
44861 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",38);
44862 }
44863
44864 if(!p_igetl(&guysbuf[i].misc7,f))
44865 {
44866 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",39);
44867 }
44868
44869 if(!p_igetl(&guysbuf[i].misc8,f))
44870 {
44871 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",40);
44872 }
44873
44874 if(!p_igetl(&guysbuf[i].misc9,f))
44875 {
44876 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",41);
44877 }
44878
44879 if(!p_igetl(&guysbuf[i].misc10,f))
44880 {
44881 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",42);
44882 }
44883
44884 if(!p_igetw(&guysbuf[i].bgsfx,f))
44885 {
44886 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",43);
44887 }
44888
44889 if(!p_igetw(&guysbuf[i].bosspal,f))
44890 {
44891 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",44);
44892 }
44893
44894 if(!p_igetw(&guysbuf[i].extend,f))
44895 {
44896 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",45);
44897 }
44898
44899 for(int32_t j=0; j < edefLAST; j++)
44900 {
44901 if(!p_getc(&guysbuf[i].defense[j],f))
44902 {
44903 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",46);
44904 }
44905 }
44906
44907 if(!p_getc(&guysbuf[i].hitsfx,f))
44908 {
44909 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",47);
44910 }
44911
44912 if(!p_getc(&guysbuf[i].deadsfx,f))
44913 {
44914 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",48);
44915 }
44916
44917 if(!p_igetl(&guysbuf[i].misc11,f))
44918 {
44919 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",49);
44920 }
44921
44922 if(!p_igetl(&guysbuf[i].misc12,f))
44923 {
44924 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",50);
44925 }
44926
44927 //New 2.6 defences
44928 for(int32_t j=edefLAST; j < edefLAST255; j++)
44929 {
44930 if(!p_getc(&guysbuf[i].defense[j],f))
44931 {
44932 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",51);
44933 }
44934 }
44935
44936 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
44937 if(!p_igetl(&guysbuf[i].txsz,f))
44938 {
44939 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",52);
44940 }
44941 if(!p_igetl(&guysbuf[i].tysz,f))
44942 {
44943 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",53);
44944 }
44945 if(!p_igetl(&guysbuf[i].hxsz,f))
44946 {
44947 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",54);
44948 }
44949 if(!p_igetl(&guysbuf[i].hysz,f))
44950 {
44951 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",55);
44952 }
44953 if(!p_igetl(&guysbuf[i].hzsz,f))
44954 {
44955 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",56);
44956 }
44957 // These are not fixed types, but ints, so they are safe to use here.
44958 if(!p_igetl(&guysbuf[i].hxofs,f))
44959 {
44960 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",57);
44961 }
44962 if(!p_igetl(&guysbuf[i].hyofs,f))
44963 {
44964 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",58);
44965 }
44966 if(!p_igetl(&guysbuf[i].xofs,f))
44967 {
44968 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",59);
44969 }
44970 if(!p_igetl(&guysbuf[i].yofs,f))
44971 {
44972 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",60);
44973 }
44974 if(!p_igetl(&guysbuf[i].zofs,f))
44975 {
44976 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",61);
44977 }
44978 if(!p_igetl(&guysbuf[i].wpnsprite,f))
44979 {
44980 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",62);
44981 }
44982 if(!p_igetl(&guysbuf[i].SIZEflags,f))
44983 {
44984 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",63);
44985 }
44986 if(!p_igetl(&guysbuf[i].frozentile,f))
44987 {
44988 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",64);
44989 }
44990 if(!p_igetl(&guysbuf[i].frozencset,f))
44991 {
44992 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",65);
44993 }
44994 if(!p_igetl(&guysbuf[i].frozenclock,f))
44995 {
44996 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",66);
44997 }
44998
44999 for ( int32_t q = 0; q < 10; q++ )
45000 {
45001 if(!p_igetw(&guysbuf[i].frozenmisc[q],f))
45002 {
45003 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",67);
45004 }
45005 }
45006 if(!p_igetw(&guysbuf[i].firesfx,f))
45007 {
45008 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",68);
45009 }
45010 //misc 16->31
45011 if(!p_igetl(&guysbuf[i].misc16,f))
45012 {
45013 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",69);
45014 }
45015 if(!p_igetl(&guysbuf[i].misc17,f))
45016 {
45017 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",70);
45018 }
45019 if(!p_igetl(&guysbuf[i].misc18,f))
45020 {
45021 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",71);
45022 }
45023 if(!p_igetl(&guysbuf[i].misc19,f))
45024 {
45025 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",72);
45026 }
45027 if(!p_igetl(&guysbuf[i].misc20,f))
45028 {
45029 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",73);
45030 }
45031 if(!p_igetl(&guysbuf[i].misc21,f))
45032 {
45033 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",74);
45034 }
45035 if(!p_igetl(&guysbuf[i].misc22,f))
45036 {
45037 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",75);
45038 }
45039 if(!p_igetl(&guysbuf[i].misc23,f))
45040 {
45041 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",76);
45042 }
45043 if(!p_igetl(&guysbuf[i].misc24,f))
45044 {
45045 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",77);
45046 }
45047 if(!p_igetl(&guysbuf[i].misc25,f))
45048 {
45049 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",78);
45050 }
45051 if(!p_igetl(&guysbuf[i].misc26,f))
45052 {
45053 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",79);
45054 }
45055 if(!p_igetl(&guysbuf[i].misc27,f))
45056 {
45057 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",80);
45058 }
45059 if(!p_igetl(&guysbuf[i].misc28,f))
45060 {
45061 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",81);
45062 }
45063 if(!p_igetl(&guysbuf[i].misc29,f))
45064 {
45065 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",82);
45066 }
45067 if(!p_igetl(&guysbuf[i].misc30,f))
45068 {
45069 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",83);
45070 }
45071 if(!p_igetl(&guysbuf[i].misc31,f))
45072 {
45073 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",84);
45074 }
45075 if(!p_igetl(&guysbuf[i].misc32,f))
45076 {
45077 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",85);
45078 }
45079 for ( int32_t q = 0; q < 32; q++ )
45080 {
45081 if(!p_igetl(&guysbuf[i].movement[q],f))
45082 {
45083 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",86);
45084 }
45085 }
45086 for ( int32_t q = 0; q < 32; q++ )
45087 {
45088 if(!p_igetl(&guysbuf[i].new_weapon[q],f))
45089 {
45090 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",87);
45091 }
45092 }
45093 if(!p_igetw(&guysbuf[i].script,f))
45094 {
45095 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",88);
45096 }
45097 for ( int32_t q = 0; q < 8; q++ )
45098 {
45099 if(!p_igetl(&guysbuf[i].initD[q],f))
45100 {
45101 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",89);
45102 }
45103 }
45104 for ( int32_t q = 0; q < 2; q++ )
45105 {
45106 if(!p_igetl(&guysbuf[i].initA[q],f))
45107 {
45108 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",90);
45109 }
45110 }
45111 if(!p_igetl(&guysbuf[i].editorflags,f))
45112 {
45113 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",91);
45114 }
45115 //somehow forgot these in the older builds -Z
45116 if(!p_igetl(&guysbuf[i].misc13,f))
45117 {
45118 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",92);
45119 }
45120 if(!p_igetl(&guysbuf[i].misc14,f))
45121 {
45122 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",93);
45123 }
45124 if(!p_igetl(&guysbuf[i].misc15,f))
45125 {
45126 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",94);
45127 }
45128
45129 //Enemy Editor InitD[] labels
45130 for ( int32_t q = 0; q < 8; q++ )
45131 {
45132 for ( int32_t w = 0; w < 65; w++ )
45133 {
45134 if(!p_getc(&guysbuf[i].initD_label[q][w],f))
45135 {
45136 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",95);
45137 }
45138 }
45139 for ( int32_t w = 0; w < 65; w++ )
45140 {
45141 if(!p_getc(&guysbuf[i].weapon_initD_label[q][w],f))
45142 {
45143 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",96);
45144 }
45145 }
45146 }
45147 if(!p_igetw(&guysbuf[i].weaponscript,f))
45148 {
45149 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",97);
45150 }
45151 //eweapon initD
45152 for ( int32_t q = 0; q < 8; q++ )
45153 {
45154 if(!p_igetl(&guysbuf[i].weap_initiald[q],f))
45155 {
45156 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",98);
45157 }
45158 }
45159
45160 }
45161 }
45162
45163 void FFScript::write_enemies(PACKFILE *f, int32_t vers_id)
45164 {
45165 if ( !f ) return;
45166 for(int32_t i=0; i<MAXGUYS; i++)
45167 {
45168 if(!p_iputl(guysbuf[i].flags,f))
45169 {
45170 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",6);
45171 }
45172
45173 if(!p_iputl(guysbuf[i].flags2,f))
45174 {
45175 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",7);
45176 }
45177
45178 if(!p_iputl(guysbuf[i].tile,f))
45179 {
45180 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",8);
45181 }
45182
45183 if(!p_putc(guysbuf[i].width,f))
45184 {
45185 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",9);
45186 }
45187
45188 if(!p_putc(guysbuf[i].height,f))
45189 {
45190 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",10);
45191 }
45192
45193 if(!p_iputl(guysbuf[i].s_tile,f))
45194 {
45195 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",11);
45196 }
45197
45198 if(!p_putc(guysbuf[i].s_width,f))
45199 {
45200 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",12);
45201 }
45202
45203 if(!p_putc(guysbuf[i].s_height,f))
45204 {
45205 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",13);
45206 }
45207
45208 if(!p_iputl(guysbuf[i].e_tile,f))
45209 {
45210 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",14);
45211 }
45212
45213 if(!p_putc(guysbuf[i].e_width,f))
45214 {
45215 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",15);
45216 }
45217
45218 if(!p_putc(guysbuf[i].e_height,f))
45219 {
45220 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",16);
45221 }
45222
45223 if(!p_iputw(guysbuf[i].hp,f))
45224 {
45225 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",17);
45226 }
45227
45228 if(!p_iputw(guysbuf[i].family,f))
45229 {
45230 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",18);
45231 }
45232
45233 if(!p_iputw(guysbuf[i].cset,f))
45234 {
45235 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",19);
45236 }
45237
45238 if(!p_iputw(guysbuf[i].anim,f))
45239 {
45240 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",20);
45241 }
45242
45243 if(!p_iputw(guysbuf[i].e_anim,f))
45244 {
45245 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",21);
45246 }
45247
45248 if(!p_iputw(guysbuf[i].frate,f))
45249 {
45250 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",22);
45251 }
45252
45253 if(!p_iputw(guysbuf[i].e_frate,f))
45254 {
45255 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",23);
45256 }
45257
45258 if(!p_iputw(guysbuf[i].dp,f))
45259 {
45260 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",24);
45261 }
45262
45263 if(!p_iputw(guysbuf[i].wdp,f))
45264 {
45265 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",25);
45266 }
45267
45268 if(!p_iputw(guysbuf[i].weapon,f))
45269 {
45270 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",26);
45271 }
45272
45273 if(!p_iputw(guysbuf[i].rate,f))
45274 {
45275 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",27);
45276 }
45277
45278 if(!p_iputw(guysbuf[i].hrate,f))
45279 {
45280 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",28);
45281 }
45282
45283 if(!p_iputw(guysbuf[i].step,f))
45284 {
45285 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",29);
45286 }
45287
45288 if(!p_iputw(guysbuf[i].homing,f))
45289 {
45290 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",30);
45291 }
45292
45293 if(!p_iputw(guysbuf[i].grumble,f))
45294 {
45295 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",31);
45296 }
45297
45298 if(!p_iputw(guysbuf[i].item_set,f))
45299 {
45300 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",32);
45301 }
45302
45303 if(!p_iputl(guysbuf[i].misc1,f))
45304 {
45305 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",33);
45306 }
45307
45308 if(!p_iputl(guysbuf[i].misc2,f))
45309 {
45310 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",34);
45311 }
45312
45313 if(!p_iputl(guysbuf[i].misc3,f))
45314 {
45315 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",35);
45316 }
45317
45318 if(!p_iputl(guysbuf[i].misc4,f))
45319 {
45320 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",36);
45321 }
45322
45323 if(!p_iputl(guysbuf[i].misc5,f))
45324 {
45325 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",37);
45326 }
45327
45328 if(!p_iputl(guysbuf[i].misc6,f))
45329 {
45330 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",38);
45331 }
45332
45333 if(!p_iputl(guysbuf[i].misc7,f))
45334 {
45335 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",39);
45336 }
45337
45338 if(!p_iputl(guysbuf[i].misc8,f))
45339 {
45340 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",40);
45341 }
45342
45343 if(!p_iputl(guysbuf[i].misc9,f))
45344 {
45345 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",41);
45346 }
45347
45348 if(!p_iputl(guysbuf[i].misc10,f))
45349 {
45350 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",42);
45351 }
45352
45353 if(!p_iputw(guysbuf[i].bgsfx,f))
45354 {
45355 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",43);
45356 }
45357
45358 if(!p_iputw(guysbuf[i].bosspal,f))
45359 {
45360 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",44);
45361 }
45362
45363 if(!p_iputw(guysbuf[i].extend,f))
45364 {
45365 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",45);
45366 }
45367
45368 for(int32_t j=0; j < edefLAST; j++)
45369 {
45370 if(!p_putc(guysbuf[i].defense[j],f))
45371 {
45372 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",46);
45373 }
45374 }
45375
45376 if(!p_putc(guysbuf[i].hitsfx,f))
45377 {
45378 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",47);
45379 }
45380
45381 if(!p_putc(guysbuf[i].deadsfx,f))
45382 {
45383 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",48);
45384 }
45385
45386 if(!p_iputl(guysbuf[i].misc11,f))
45387 {
45388 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",49);
45389 }
45390
45391 if(!p_iputl(guysbuf[i].misc12,f))
45392 {
45393 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",50);
45394 }
45395
45396 //New 2.6 defences
45397 for(int32_t j=edefLAST; j < edefLAST255; j++)
45398 {
45399 if(!p_putc(guysbuf[i].defense[j],f))
45400 {
45401 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",51);
45402 }
45403 }
45404
45405 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
45406 if(!p_iputl(guysbuf[i].txsz,f))
45407 {
45408 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",52);
45409 }
45410 if(!p_iputl(guysbuf[i].tysz,f))
45411 {
45412 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",53);
45413 }
45414 if(!p_iputl(guysbuf[i].hxsz,f))
45415 {
45416 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",54);
45417 }
45418 if(!p_iputl(guysbuf[i].hysz,f))
45419 {
45420 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",55);
45421 }
45422 if(!p_iputl(guysbuf[i].hzsz,f))
45423 {
45424 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",56);
45425 }
45426 // These are not fixed types, but ints, so they are safe to use here.
45427 if(!p_iputl(guysbuf[i].hxofs,f))
45428 {
45429 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",57);
45430 }
45431 if(!p_iputl(guysbuf[i].hyofs,f))
45432 {
45433 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",58);
45434 }
45435 if(!p_iputl(guysbuf[i].xofs,f))
45436 {
45437 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",59);
45438 }
45439 if(!p_iputl(guysbuf[i].yofs,f))
45440 {
45441 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",60);
45442 }
45443 if(!p_iputl(guysbuf[i].zofs,f))
45444 {
45445 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",61);
45446 }
45447 if(!p_iputl(guysbuf[i].wpnsprite,f))
45448 {
45449 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",62);
45450 }
45451 if(!p_iputl(guysbuf[i].SIZEflags,f))
45452 {
45453 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",63);
45454 }
45455 if(!p_iputl(guysbuf[i].frozentile,f))
45456 {
45457 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",64);
45458 }
45459 if(!p_iputl(guysbuf[i].frozencset,f))
45460 {
45461 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",65);
45462 }
45463 if(!p_iputl(guysbuf[i].frozenclock,f))
45464 {
45465 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",66);
45466 }
45467
45468 for ( int32_t q = 0; q < 10; q++ )
45469 {
45470 if(!p_iputw(guysbuf[i].frozenmisc[q],f))
45471 {
45472 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",67);
45473 }
45474 }
45475 if(!p_iputw(guysbuf[i].firesfx,f))
45476 {
45477 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",68);
45478 }
45479 //misc 16->31
45480 if(!p_iputl(guysbuf[i].misc16,f))
45481 {
45482 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",69);
45483 }
45484 if(!p_iputl(guysbuf[i].misc17,f))
45485 {
45486 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",70);
45487 }
45488 if(!p_iputl(guysbuf[i].misc18,f))
45489 {
45490 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",71);
45491 }
45492 if(!p_iputl(guysbuf[i].misc19,f))
45493 {
45494 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",72);
45495 }
45496 if(!p_iputl(guysbuf[i].misc20,f))
45497 {
45498 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",73);
45499 }
45500 if(!p_iputl(guysbuf[i].misc21,f))
45501 {
45502 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",74);
45503 }
45504 if(!p_iputl(guysbuf[i].misc22,f))
45505 {
45506 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",75);
45507 }
45508 if(!p_iputl(guysbuf[i].misc23,f))
45509 {
45510 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",76);
45511 }
45512 if(!p_iputl(guysbuf[i].misc24,f))
45513 {
45514 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",77);
45515 }
45516 if(!p_iputl(guysbuf[i].misc25,f))
45517 {
45518 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",78);
45519 }
45520 if(!p_iputl(guysbuf[i].misc26,f))
45521 {
45522 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",79);
45523 }
45524 if(!p_iputl(guysbuf[i].misc27,f))
45525 {
45526 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",80);
45527 }
45528 if(!p_iputl(guysbuf[i].misc28,f))
45529 {
45530 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",81);
45531 }
45532 if(!p_iputl(guysbuf[i].misc29,f))
45533 {
45534 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",82);
45535 }
45536 if(!p_iputl(guysbuf[i].misc30,f))
45537 {
45538 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",83);
45539 }
45540 if(!p_iputl(guysbuf[i].misc31,f))
45541 {
45542 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",84);
45543 }
45544 if(!p_iputl(guysbuf[i].misc32,f))
45545 {
45546 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",85);
45547 }
45548 for ( int32_t q = 0; q < 32; q++ )
45549 {
45550 if(!p_iputl(guysbuf[i].movement[q],f))
45551 {
45552 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",86);
45553 }
45554 }
45555 for ( int32_t q = 0; q < 32; q++ )
45556 {
45557 if(!p_iputl(guysbuf[i].new_weapon[q],f))
45558 {
45559 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",87);
45560 }
45561 }
45562 if(!p_iputw(guysbuf[i].script,f))
45563 {
45564 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",88);
45565 }
45566 for ( int32_t q = 0; q < 8; q++ )
45567 {
45568 if(!p_iputl(guysbuf[i].initD[q],f))
45569 {
45570 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",89);
45571 }
45572 }
45573 for ( int32_t q = 0; q < 2; q++ )
45574 {
45575 if(!p_iputl(guysbuf[i].initA[q],f))
45576 {
45577 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",90);
45578 }
45579 }
45580 if(!p_iputl(guysbuf[i].editorflags,f))
45581 {
45582 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",91);
45583 }
45584 //somehow forgot these in the older builds -Z
45585 if(!p_iputl(guysbuf[i].misc13,f))
45586 {
45587 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",92);
45588 }
45589 if(!p_iputl(guysbuf[i].misc14,f))
45590 {
45591 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",93);
45592 }
45593 if(!p_iputl(guysbuf[i].misc15,f))
45594 {
45595 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",94);
45596 }
45597
45598 //Enemy Editor InitD[] labels
45599 for ( int32_t q = 0; q < 8; q++ )
45600 {
45601 for ( int32_t w = 0; w < 65; w++ )
45602 {
45603 if(!p_putc(guysbuf[i].initD_label[q][w],f))
45604 {
45605 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",95);
45606 }
45607 }
45608 for ( int32_t w = 0; w < 65; w++ )
45609 {
45610 if(!p_putc(guysbuf[i].weapon_initD_label[q][w],f))
45611 {
45612 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",96);
45613 }
45614 }
45615 }
45616 if(!p_iputw(guysbuf[i].weaponscript,f))
45617 {
45618 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",97);
45619 }
45620 //eweapon initD
45621 for ( int32_t q = 0; q < 8; q++ )
45622 {
45623 if(!p_iputl(guysbuf[i].weap_initiald[q],f))
45624 {
45625 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",98);
45626 }
45627 }
45628
45629 }
45630 }
45631
45632
45633 void FFScript::write_items(PACKFILE *f, int32_t vers_id)
45634 {
45635 for(int32_t i=0; i<MAXITEMS; i++)
45636 {
45637 if(!p_iputl(itemsbuf[i].tile,f))
45638 {
45639 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",6);
45640 }
45641
45642 if(!p_putc(itemsbuf[i].misc_flags,f))
45643 {
45644 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",7);
45645 }
45646
45647 if(!p_putc(itemsbuf[i].csets,f))
45648 {
45649 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",8);
45650 }
45651
45652 if(!p_putc(itemsbuf[i].frames,f))
45653 {
45654 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",9);
45655 }
45656
45657 if(!p_putc(itemsbuf[i].speed,f))
45658 {
45659 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",10);
45660 }
45661
45662 if(!p_putc(itemsbuf[i].delay,f))
45663 {
45664 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",11);
45665 }
45666
45667 if(!p_iputl(itemsbuf[i].ltm,f))
45668 {
45669 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",12);
45670 }
45671
45672 if(!p_iputl(itemsbuf[i].family,f))
45673 {
45674 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",13);
45675 }
45676
45677 if(!p_putc(itemsbuf[i].fam_type,f))
45678 {
45679 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",14);
45680 }
45681
45682 if(!p_iputl(itemsbuf[i].power,f))
45683 {
45684 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",14);
45685 }
45686
45687 if(!p_iputl(itemsbuf[i].flags,f))
45688 {
45689 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",15);
45690 }
45691
45692 if(!p_iputw(itemsbuf[i].script,f))
45693 {
45694 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",16);
45695 }
45696
45697 if(!p_putc(itemsbuf[i].count,f))
45698 {
45699 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",17);
45700 }
45701
45702 if(!p_iputw(itemsbuf[i].amount,f))
45703 {
45704 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",18);
45705 }
45706
45707 if(!p_iputw(itemsbuf[i].collect_script,f))
45708 {
45709 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",19);
45710 }
45711
45712 if(!p_iputw(itemsbuf[i].setmax,f))
45713 {
45714 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",21);
45715 }
45716
45717 if(!p_iputw(itemsbuf[i].max,f))
45718 {
45719 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",22);
45720 }
45721
45722 if(!p_putc(itemsbuf[i].playsound,f))
45723 {
45724 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",23);
45725 }
45726
45727 for(int32_t j=0; j<8; j++)
45728 {
45729 if(!p_iputl(itemsbuf[i].initiald[j],f))
45730 {
45731 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",24);
45732 }
45733 }
45734
45735 for(int32_t j=0; j<2; j++)
45736 {
45737 if(!p_putc(itemsbuf[i].initiala[j],f))
45738 {
45739 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",25);
45740 }
45741 }
45742
45743 if(!p_putc(itemsbuf[i].wpn,f))
45744 {
45745 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",26);
45746 }
45747
45748 if(!p_putc(itemsbuf[i].wpn2,f))
45749 {
45750 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",27);
45751 }
45752
45753 if(!p_putc(itemsbuf[i].wpn3,f))
45754 {
45755 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",28);
45756 }
45757
45758 if(!p_putc(itemsbuf[i].wpn4,f))
45759 {
45760 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",29);
45761 }
45762
45763 if(!p_putc(itemsbuf[i].wpn5,f))
45764 {
45765 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",30);
45766 }
45767
45768 if(!p_putc(itemsbuf[i].wpn6,f))
45769 {
45770 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",31);
45771 }
45772
45773 if(!p_putc(itemsbuf[i].wpn7,f))
45774 {
45775 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",32);
45776 }
45777
45778 if(!p_putc(itemsbuf[i].wpn8,f))
45779 {
45780 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",33);
45781 }
45782
45783 if(!p_putc(itemsbuf[i].wpn9,f))
45784 {
45785 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",34);
45786 }
45787
45788 if(!p_putc(itemsbuf[i].wpn10,f))
45789 {
45790 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",35);
45791 }
45792
45793 if(!p_putc(itemsbuf[i].pickup_hearts,f))
45794 {
45795 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",36);
45796 }
45797
45798 if(!p_iputl(itemsbuf[i].misc1,f))
45799 {
45800 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",37);
45801 }
45802
45803 if(!p_iputl(itemsbuf[i].misc2,f))
45804 {
45805 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",38);
45806 }
45807
45808 if(!p_putc(itemsbuf[i].cost_amount[0],f))
45809 {
45810 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",39);
45811 }
45812
45813 if(!p_iputl(itemsbuf[i].misc3,f))
45814 {
45815 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",40);
45816 }
45817
45818 if(!p_iputl(itemsbuf[i].misc4,f))
45819 {
45820 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",41);
45821 }
45822
45823 if(!p_iputl(itemsbuf[i].misc5,f))
45824 {
45825 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",42);
45826 }
45827
45828 if(!p_iputl(itemsbuf[i].misc6,f))
45829 {
45830 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",43);
45831 }
45832
45833 if(!p_iputl(itemsbuf[i].misc7,f))
45834 {
45835 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",44);
45836 }
45837
45838 if(!p_iputl(itemsbuf[i].misc8,f))
45839 {
45840 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",45);
45841 }
45842
45843 if(!p_iputl(itemsbuf[i].misc9,f))
45844 {
45845 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",46);
45846 }
45847
45848 if(!p_iputl(itemsbuf[i].misc10,f))
45849 {
45850 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",47);
45851 }
45852
45853 if(!p_putc(itemsbuf[i].usesound,f))
45854 {
45855 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",48);
45856 }
45857
45858 if(!p_putc(itemsbuf[i].usesound2,f))
45859 {
45860 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",48);
45861 }
45862
45863 //New itemdata vars -Z
45864 //! version 27
45865
45866 if(!p_putc(itemsbuf[i].useweapon,f))
45867 {
45868 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",49);
45869 }
45870 if(!p_putc(itemsbuf[i].usedefence,f))
45871 {
45872 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",50);
45873 }
45874 if(!p_iputl(itemsbuf[i].weaprange,f))
45875 {
45876 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",51);
45877 }
45878 if(!p_iputl(itemsbuf[i].weapduration,f))
45879 {
45880 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",52);
45881 }
45882 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ ) {
45883 if(!p_iputl(itemsbuf[i].weap_pattern[q],f))
45884 {
45885 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",53);
45886 }
45887 }
45888 //version 28
45889 if(!p_iputl(itemsbuf[i].duplicates,f))
45890 {
45891 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",54);
45892 }
45893 for ( int32_t q = 0; q < INITIAL_D; q++ )
45894 {
45895 if(!p_iputl(itemsbuf[i].weap_initiald[q],f))
45896 {
45897 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",55);
45898 }
45899 }
45900 for ( int32_t q = 0; q < INITIAL_A; q++ )
45901 {
45902 if(!p_putc(itemsbuf[i].weap_initiala[q],f))
45903 {
45904 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",56);
45905 }
45906 }
45907
45908 if(!p_putc(itemsbuf[i].drawlayer,f))
45909 {
45910 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",57);
45911 }
45912
45913
45914 if(!p_iputl(itemsbuf[i].hxofs,f))
45915 {
45916 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",58);
45917 }
45918 if(!p_iputl(itemsbuf[i].hyofs,f))
45919 {
45920 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",59);
45921 }
45922 if(!p_iputl(itemsbuf[i].hxsz,f))
45923 {
45924 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",60);
45925 }
45926 if(!p_iputl(itemsbuf[i].hysz,f))
45927 {
45928 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",61);
45929 }
45930 if(!p_iputl(itemsbuf[i].hzsz,f))
45931 {
45932 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",62);
45933 }
45934 if(!p_iputl(itemsbuf[i].xofs,f))
45935 {
45936 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",63);
45937 }
45938 if(!p_iputl(itemsbuf[i].yofs,f))
45939 {
45940 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",64);
45941 }
45942 if(!p_iputl(itemsbuf[i].weap_hxofs,f))
45943 {
45944 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",65);
45945 }
45946 if(!p_iputl(itemsbuf[i].weap_hyofs,f))
45947 {
45948 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",66);
45949 }
45950 if(!p_iputl(itemsbuf[i].weap_hxsz,f))
45951 {
45952 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",67);
45953 }
45954 if(!p_iputl(itemsbuf[i].weap_hysz,f))
45955 {
45956 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",68);
45957 }
45958 if(!p_iputl(itemsbuf[i].weap_hzsz,f))
45959 {
45960 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",69);
45961 }
45962 if(!p_iputl(itemsbuf[i].weap_xofs,f))
45963 {
45964 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",70);
45965 }
45966 if(!p_iputl(itemsbuf[i].weap_yofs,f))
45967 {
45968 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",71);
45969 }
45970 if(!p_iputw(itemsbuf[i].weaponscript,f))
45971 {
45972 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",72);
45973 }
45974 if(!p_iputl(itemsbuf[i].wpnsprite,f))
45975 {
45976 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",73);
45977 }
45978 if(!p_iputl(itemsbuf[i].magiccosttimer[0],f))
45979 {
45980 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",74);
45981 }
45982 if(!p_iputl(itemsbuf[i].overrideFLAGS,f))
45983 {
45984 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",75);
45985 }
45986 if(!p_iputl(itemsbuf[i].tilew,f))
45987 {
45988 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",76);
45989 }
45990 if(!p_iputl(itemsbuf[i].tileh,f))
45991 {
45992 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",77);
45993 }
45994 if(!p_iputl(itemsbuf[i].weapoverrideFLAGS,f))
45995 {
45996 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",78);
45997 }
45998 if(!p_iputl(itemsbuf[i].weap_tilew,f))
45999 {
46000 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",79);
46001 }
46002 if(!p_iputl(itemsbuf[i].weap_tileh,f))
46003 {
46004 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",80);
46005 }
46006 if(!p_iputl(itemsbuf[i].pickup,f))
46007 {
46008 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",81);
46009 }
46010 if(!p_iputw(itemsbuf[i].pstring,f))
46011 {
46012 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",82);
46013 }
46014 if(!p_iputw(itemsbuf[i].pickup_string_flags,f))
46015 {
46016 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",83);
46017 }
46018
46019 if(!p_putc(itemsbuf[i].cost_counter[0],f))
46020 {
46021 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",84);
46022 }
46023
46024 //InitD[] labels
46025 for ( int32_t q = 0; q < 8; q++ )
46026 {
46027 for ( int32_t w = 0; w < 65; w++ )
46028 {
46029 if(!p_putc(itemsbuf[i].initD_label[q][w],f))
46030 {
46031 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",85);
46032 }
46033 }
46034 for ( int32_t w = 0; w < 65; w++ )
46035 {
46036 if(!p_putc(itemsbuf[i].weapon_initD_label[q][w],f))
46037 {
46038 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",86);
46039 }
46040 }
46041 for ( int32_t w = 0; w < 65; w++ )
46042 {
46043 if(!p_putc(itemsbuf[i].sprite_initD_label[q][w],f))
46044 {
46045 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",87);
46046 }
46047 }
46048 if(!p_iputl(itemsbuf[i].sprite_initiald[q],f))
46049 {
46050 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",88);
46051 }
46052 }
46053 for ( int32_t q = 0; q < 2; q++ )
46054 {
46055 if(!p_putc(itemsbuf[i].sprite_initiala[q],f))
46056 {
46057 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",89);
46058 }
46059
46060 }
46061 if(!p_iputw(itemsbuf[i].sprite_script,f))
46062 {
46063 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",90);
46064 }
46065
46066
46067 }
46068 }
46069
46070 void FFScript::read_items(PACKFILE *f, int32_t vers_id)
46071 {
46072 for(int32_t i=0; i<MAXITEMS; i++)
46073 {
46074 if(!p_igetl(&itemsbuf[i].tile,f))
46075 {
46076 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",6);
46077 }
46078
46079 if(!p_getc(&itemsbuf[i].misc_flags,f))
46080 {
46081 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",7);
46082 }
46083
46084 if(!p_getc(&itemsbuf[i].csets,f))
46085 {
46086 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",8);
46087 }
46088
46089 if(!p_getc(&itemsbuf[i].frames,f))
46090 {
46091 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",9);
46092 }
46093
46094 if(!p_getc(&itemsbuf[i].speed,f))
46095 {
46096 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",10);
46097 }
46098
46099 if(!p_getc(&itemsbuf[i].delay,f))
46100 {
46101 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",11);
46102 }
46103
46104 if(!p_igetl(&itemsbuf[i].ltm,f))
46105 {
46106 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",12);
46107 }
46108
46109 if(!p_igetl(&itemsbuf[i].family,f))
46110 {
46111 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",13);
46112 }
46113
46114 if(!p_getc(&itemsbuf[i].fam_type,f))
46115 {
46116 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",14);
46117 }
46118
46119 if(!p_igetl(&itemsbuf[i].power,f))
46120 {
46121 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",14);
46122 }
46123
46124 if(!p_igetl(&itemsbuf[i].flags,f))
46125 {
46126 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",15);
46127 }
46128
46129 if(!p_igetw(&itemsbuf[i].script,f))
46130 {
46131 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",16);
46132 }
46133
46134 if(!p_getc(&itemsbuf[i].count,f))
46135 {
46136 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",17);
46137 }
46138
46139 if(!p_igetw(&itemsbuf[i].amount,f))
46140 {
46141 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",18);
46142 }
46143
46144 if(!p_igetw(&itemsbuf[i].collect_script,f))
46145 {
46146 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",19);
46147 }
46148
46149 if(!p_igetw(&itemsbuf[i].setmax,f))
46150 {
46151 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",21);
46152 }
46153
46154 if(!p_igetw(&itemsbuf[i].max,f))
46155 {
46156 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",22);
46157 }
46158
46159 if(!p_getc(&itemsbuf[i].playsound,f))
46160 {
46161 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",23);
46162 }
46163
46164 for(int32_t j=0; j<8; j++)
46165 {
46166 if(!p_igetl(&itemsbuf[i].initiald[j],f))
46167 {
46168 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",24);
46169 }
46170 }
46171
46172 for(int32_t j=0; j<2; j++)
46173 {
46174 if(!p_getc(&itemsbuf[i].initiala[j],f))
46175 {
46176 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",25);
46177 }
46178 }
46179
46180 if(!p_getc(&itemsbuf[i].wpn,f))
46181 {
46182 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",26);
46183 }
46184
46185 if(!p_getc(&itemsbuf[i].wpn2,f))
46186 {
46187 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",27);
46188 }
46189
46190 if(!p_getc(&itemsbuf[i].wpn3,f))
46191 {
46192 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",28);
46193 }
46194
46195 if(!p_getc(&itemsbuf[i].wpn4,f))
46196 {
46197 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",29);
46198 }
46199
46200 if(!p_getc(&itemsbuf[i].wpn5,f))
46201 {
46202 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",30);
46203 }
46204
46205 if(!p_getc(&itemsbuf[i].wpn6,f))
46206 {
46207 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",31);
46208 }
46209
46210 if(!p_getc(&itemsbuf[i].wpn7,f))
46211 {
46212 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",32);
46213 }
46214
46215 if(!p_getc(&itemsbuf[i].wpn8,f))
46216 {
46217 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",33);
46218 }
46219
46220 if(!p_getc(&itemsbuf[i].wpn9,f))
46221 {
46222 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",34);
46223 }
46224
46225 if(!p_getc(&itemsbuf[i].wpn10,f))
46226 {
46227 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",35);
46228 }
46229
46230 if(!p_getc(&itemsbuf[i].pickup_hearts,f))
46231 {
46232 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",36);
46233 }
46234
46235 if(!p_igetl(&itemsbuf[i].misc1,f))
46236 {
46237 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",37);
46238 }
46239
46240 if(!p_igetl(&itemsbuf[i].misc2,f))
46241 {
46242 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",38);
46243 }
46244
46245 if(!p_getc(&itemsbuf[i].cost_amount[0],f))
46246 {
46247 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",39);
46248 }
46249
46250 if(!p_igetl(&itemsbuf[i].misc3,f))
46251 {
46252 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",40);
46253 }
46254
46255 if(!p_igetl(&itemsbuf[i].misc4,f))
46256 {
46257 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",41);
46258 }
46259
46260 if(!p_igetl(&itemsbuf[i].misc5,f))
46261 {
46262 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",42);
46263 }
46264
46265 if(!p_igetl(&itemsbuf[i].misc6,f))
46266 {
46267 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",43);
46268 }
46269
46270 if(!p_igetl(&itemsbuf[i].misc7,f))
46271 {
46272 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",44);
46273 }
46274
46275 if(!p_igetl(&itemsbuf[i].misc8,f))
46276 {
46277 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",45);
46278 }
46279
46280 if(!p_igetl(&itemsbuf[i].misc9,f))
46281 {
46282 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",46);
46283 }
46284
46285 if(!p_igetl(&itemsbuf[i].misc10,f))
46286 {
46287 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",47);
46288 }
46289
46290 if(!p_getc(&itemsbuf[i].usesound,f))
46291 {
46292 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",48);
46293 }
46294
46295 if(!p_getc(&itemsbuf[i].usesound2,f))
46296 {
46297 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",48);
46298 }
46299
46300 //New itemdata vars -Z
46301 //! version 27
46302
46303 if(!p_getc(&itemsbuf[i].useweapon,f))
46304 {
46305 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",49);
46306 }
46307 if(!p_getc(&itemsbuf[i].usedefence,f))
46308 {
46309 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",50);
46310 }
46311 if(!p_igetl(&itemsbuf[i].weaprange,f))
46312 {
46313 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",51);
46314 }
46315 if(!p_igetl(&itemsbuf[i].weapduration,f))
46316 {
46317 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",52);
46318 }
46319 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ ) {
46320 if(!p_igetl(&itemsbuf[i].weap_pattern[q],f))
46321 {
46322 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",53);
46323 }
46324 }
46325 //version 28
46326 if(!p_igetl(&itemsbuf[i].duplicates,f))
46327 {
46328 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",54);
46329 }
46330 for ( int32_t q = 0; q < INITIAL_D; q++ )
46331 {
46332 if(!p_igetl(&itemsbuf[i].weap_initiald[q],f))
46333 {
46334 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",55);
46335 }
46336 }
46337 for ( int32_t q = 0; q < INITIAL_A; q++ )
46338 {
46339 if(!p_getc(&itemsbuf[i].weap_initiala[q],f))
46340 {
46341 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",56);
46342 }
46343 }
46344
46345 if(!p_getc(&itemsbuf[i].drawlayer,f))
46346 {
46347 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",57);
46348 }
46349
46350
46351 if(!p_igetl(&itemsbuf[i].hxofs,f))
46352 {
46353 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",58);
46354 }
46355 if(!p_igetl(&itemsbuf[i].hyofs,f))
46356 {
46357 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",59);
46358 }
46359 if(!p_igetl(&itemsbuf[i].hxsz,f))
46360 {
46361 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",60);
46362 }
46363 if(!p_igetl(&itemsbuf[i].hysz,f))
46364 {
46365 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",61);
46366 }
46367 if(!p_igetl(&itemsbuf[i].hzsz,f))
46368 {
46369 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",62);
46370 }
46371 if(!p_igetl(&itemsbuf[i].xofs,f))
46372 {
46373 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",63);
46374 }
46375 if(!p_igetl(&itemsbuf[i].yofs,f))
46376 {
46377 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",64);
46378 }
46379 if(!p_igetl(&itemsbuf[i].weap_hxofs,f))
46380 {
46381 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",65);
46382 }
46383 if(!p_igetl(&itemsbuf[i].weap_hyofs,f))
46384 {
46385 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",66);
46386 }
46387 if(!p_igetl(&itemsbuf[i].weap_hxsz,f))
46388 {
46389 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",67);
46390 }
46391 if(!p_igetl(&itemsbuf[i].weap_hysz,f))
46392 {
46393 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",68);
46394 }
46395 if(!p_igetl(&itemsbuf[i].weap_hzsz,f))
46396 {
46397 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",69);
46398 }
46399 if(!p_igetl(&itemsbuf[i].weap_xofs,f))
46400 {
46401 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",70);
46402 }
46403 if(!p_igetl(&itemsbuf[i].weap_yofs,f))
46404 {
46405 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",71);
46406 }
46407 if(!p_igetw(&itemsbuf[i].weaponscript,f))
46408 {
46409 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",72);
46410 }
46411 if(!p_igetl(&itemsbuf[i].wpnsprite,f))
46412 {
46413 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",73);
46414 }
46415 if(!p_igetl(&itemsbuf[i].magiccosttimer[0],f))
46416 {
46417 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",74);
46418 }
46419 if(!p_igetl(&itemsbuf[i].overrideFLAGS,f))
46420 {
46421 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",75);
46422 }
46423 if(!p_igetl(&itemsbuf[i].tilew,f))
46424 {
46425 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",76);
46426 }
46427 if(!p_igetl(&itemsbuf[i].tileh,f))
46428 {
46429 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",77);
46430 }
46431 if(!p_igetl(&itemsbuf[i].weapoverrideFLAGS,f))
46432 {
46433 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",78);
46434 }
46435 if(!p_igetl(&itemsbuf[i].weap_tilew,f))
46436 {
46437 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",79);
46438 }
46439 if(!p_igetl(&itemsbuf[i].weap_tileh,f))
46440 {
46441 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",80);
46442 }
46443 if(!p_igetl(&itemsbuf[i].pickup,f))
46444 {
46445 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",81);
46446 }
46447 if(!p_igetw(&itemsbuf[i].pstring,f))
46448 {
46449 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",82);
46450 }
46451 if(!p_igetw(&itemsbuf[i].pickup_string_flags,f))
46452 {
46453 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",83);
46454 }
46455
46456 if(!p_getc(&itemsbuf[i].cost_counter[0],f))
46457 {
46458 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",84);
46459 }
46460
46461 //InitD[] labels
46462 for ( int32_t q = 0; q < 8; q++ )
46463 {
46464 for ( int32_t w = 0; w < 65; w++ )
46465 {
46466 if(!p_getc(&itemsbuf[i].initD_label[q][w],f))
46467 {
46468 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",85);
46469 }
46470 }
46471 for ( int32_t w = 0; w < 65; w++ )
46472 {
46473 if(!p_getc(&itemsbuf[i].weapon_initD_label[q][w],f))
46474 {
46475 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",86);
46476 }
46477 }
46478 for ( int32_t w = 0; w < 65; w++ )
46479 {
46480 if(!p_getc(&itemsbuf[i].sprite_initD_label[q][w],f))
46481 {
46482 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",87);
46483 }
46484 }
46485 if(!p_igetl(&itemsbuf[i].sprite_initiald[q],f))
46486 {
46487 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",88);
46488 }
46489 }
46490 for ( int32_t q = 0; q < 2; q++ )
46491 {
46492 if(!p_getc(&itemsbuf[i].sprite_initiala[q],f))
46493 {
46494 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",89);
46495 }
46496
46497 }
46498 if(!p_igetw(&itemsbuf[i].sprite_script,f))
46499 {
46500 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",90);
46501 }
46502
46503
46504 }
46505 }
46506
46507 void FFScript::write_mapscreens(PACKFILE *f,int32_t vers_id)
46508 {
46509 for(int32_t i=0; i<map_count && i<MAXMAPS2; i++)
46510 {
46511 for(int32_t j=0; j<MAPSCRS; j++)
46512 {
46513 mapscr *m = &TheMaps[i*MAPSCRS+j];
46514
46515 if(!p_putc(m->valid,f))
46516 {
46517 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46518 }
46519
46520 if(!p_putc(m->guy,f))
46521 {
46522 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46523 }
46524
46525 {
46526 if(!p_iputw(m->str,f))
46527 {
46528 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46529 }
46530 }
46531
46532 if(!p_putc(m->room,f))
46533 {
46534 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46535 }
46536
46537 if(!p_putc(m->item,f))
46538 {
46539 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46540 }
46541
46542 if(!p_putc(m->hasitem, f))
46543 {
46544 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46545 }
46546
46547 for(int32_t k=0; k<4; k++)
46548 {
46549 if(!p_putc(m->tilewarptype[k],f))
46550 {
46551 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46552 }
46553 }
46554
46555 if(!p_iputw(m->door_combo_set,f))
46556 {
46557 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46558 }
46559
46560 for(int32_t k=0; k<4; k++)
46561 {
46562 if(!p_putc(m->warpreturnx[k],f))
46563 {
46564 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46565 }
46566 }
46567
46568 for(int32_t k=0; k<4; k++)
46569 {
46570 if(!p_putc(m->warpreturny[k],f))
46571 {
46572 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46573 }
46574 }
46575
46576 if(!p_iputw(m->warpreturnc,f))
46577 {
46578 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46579 }
46580
46581 if(!p_putc(m->stairx,f))
46582 {
46583 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46584 }
46585
46586 if(!p_putc(m->stairy,f))
46587 {
46588 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46589 }
46590
46591 if(!p_putc(m->itemx,f))
46592 {
46593 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46594 }
46595
46596 if(!p_putc(m->itemy,f))
46597 {
46598 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46599 }
46600
46601 if(!p_iputw(m->color,f))
46602 {
46603 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46604 }
46605
46606 if(!p_putc(m->enemyflags,f))
46607 {
46608 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46609 }
46610
46611 for(int32_t k=0; k<4; k++)
46612 {
46613 if(!p_putc(m->door[k],f))
46614 {
46615 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46616 }
46617 }
46618
46619 for(int32_t k=0; k<4; k++)
46620 {
46621 if(!p_iputw(m->tilewarpdmap[k],f))
46622 {
46623 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46624 }
46625 }
46626
46627 for(int32_t k=0; k<4; k++)
46628 {
46629 if(!p_putc(m->tilewarpscr[k],f))
46630 {
46631 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46632 }
46633 }
46634
46635 if(!p_putc(m->tilewarpoverlayflags,f))
46636 {
46637 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46638 }
46639
46640 if(!p_putc(m->exitdir,f))
46641 {
46642 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46643 }
46644
46645 for(int32_t k=0; k<10; k++)
46646 {
46647 {
46648 if(!p_iputw(m->enemy[k],f))
46649 {
46650 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46651 }
46652 }
46653 }
46654
46655 if(!p_putc(m->pattern,f))
46656 {
46657 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46658 }
46659
46660 for(int32_t k=0; k<4; k++)
46661 {
46662 if(!p_putc(m->sidewarptype[k],f))
46663 {
46664 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46665 }
46666 }
46667
46668 if(!p_putc(m->sidewarpoverlayflags,f))
46669 {
46670 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46671 }
46672
46673 if(!p_putc(m->warparrivalx,f))
46674 {
46675 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46676 }
46677
46678 if(!p_putc(m->warparrivaly,f))
46679 {
46680 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46681 }
46682
46683 for(int32_t k=0; k<4; k++)
46684 {
46685 if(!p_putc(m->path[k],f))
46686 {
46687 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46688 }
46689 }
46690
46691 for(int32_t k=0; k<4; k++)
46692 {
46693 if(!p_putc(m->sidewarpscr[k],f))
46694 {
46695 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46696 }
46697 }
46698
46699 for(int32_t k=0; k<4; k++)
46700 {
46701 if(!p_iputw(m->sidewarpdmap[k],f))
46702 {
46703 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46704 }
46705 }
46706
46707 if(!p_putc(m->sidewarpindex,f))
46708 {
46709 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46710 }
46711
46712 if(!p_iputw(m->undercombo,f))
46713 {
46714 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46715 }
46716
46717 if(!p_putc(m->undercset,f))
46718 {
46719 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46720 }
46721
46722 if(!p_iputw(m->catchall,f))
46723 {
46724 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46725 }
46726
46727 if(!p_putc(m->flags,f))
46728 {
46729 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46730 }
46731
46732 if(!p_putc(m->flags2,f))
46733 {
46734 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46735 }
46736
46737 if(!p_putc(m->flags3,f))
46738 {
46739 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46740 }
46741
46742 if(!p_putc(m->flags4,f))
46743 {
46744 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46745 }
46746
46747 if(!p_putc(m->flags5,f))
46748 {
46749 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46750 }
46751
46752 if(!p_iputw(m->noreset,f))
46753 {
46754 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46755 }
46756
46757 if(!p_iputw(m->nocarry,f))
46758 {
46759 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46760 }
46761
46762 if(!p_putc(m->flags6,f))
46763 {
46764 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46765 }
46766
46767 if(!p_putc(m->flags7,f))
46768 {
46769 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46770 }
46771
46772 if(!p_putc(m->flags8,f))
46773 {
46774 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46775 }
46776
46777 if(!p_putc(m->flags9,f))
46778 {
46779 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46780 }
46781
46782 if(!p_putc(m->flags10,f))
46783 {
46784 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46785 }
46786
46787 if(!p_putc(m->csensitive,f))
46788 {
46789 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46790 }
46791
46792 if(!p_putc(m->oceansfx,f))
46793 {
46794 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46795 }
46796
46797 if(!p_putc(m->bosssfx,f))
46798 {
46799 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46800 }
46801
46802 if(!p_putc(m->secretsfx,f))
46803 {
46804 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46805 }
46806
46807 if(!p_putc(m->holdupsfx,f))
46808 {
46809 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46810 }
46811
46812 for(int32_t k=0; k<6; k++)
46813 {
46814 if(!p_putc(m->layermap[k],f))
46815 {
46816 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46817 }
46818 }
46819
46820 for(int32_t k=0; k<6; k++)
46821 {
46822 if(!p_putc(m->layerscreen[k],f))
46823 {
46824 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46825 }
46826 }
46827
46828 for(int32_t k=0; k<6; k++)
46829 {
46830 if(!p_putc(m->layeropacity[k],f))
46831 {
46832 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46833 }
46834 }
46835
46836 if(!p_iputw(m->timedwarptics,f))
46837 {
46838 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46839 }
46840
46841 if(!p_putc(m->nextmap,f))
46842 {
46843 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46844 }
46845
46846 if(!p_putc(m->nextscr,f))
46847 {
46848 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46849 }
46850
46851 for(int32_t k=0; k<128; k++)
46852 {
46853 if(!p_iputw(m->secretcombo[k],f))
46854 {
46855 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46856 }
46857 }
46858
46859 for(int32_t k=0; k<128; k++)
46860 {
46861 if(!p_putc(m->secretcset[k],f))
46862 {
46863 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46864 }
46865 }
46866
46867 for(int32_t k=0; k<128; k++)
46868 {
46869 if(!p_putc(m->secretflag[k],f))
46870 {
46871 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46872 }
46873 }
46874
46875 for(int32_t k=0; k<(ZCMaps[i].tileWidth)*(ZCMaps[i].tileHeight); k++)
46876 {
46877 try
46878 {
46879 if(!p_iputw(m->data[k],f))
46880 {
46881 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46882 }
46883 }
46884 catch(std::out_of_range& )
46885 {
46886 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46887 }
46888 }
46889
46890 for(int32_t k=0; k<(ZCMaps[i].tileWidth)*(ZCMaps[i].tileHeight); k++)
46891 {
46892 try
46893 {
46894 if(!p_putc(m->sflag[k], f))
46895 {
46896 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46897 }
46898 }
46899 catch(std::out_of_range& )
46900 {
46901 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46902 }
46903 }
46904
46905 for(int32_t k=0; k<(ZCMaps[i].tileWidth)*(ZCMaps[i].tileHeight); k++)
46906 {
46907 try
46908 {
46909 if(!p_putc(m->cset[k],f))
46910 {
46911 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46912 }
46913 }
46914 catch(std::out_of_range& )
46915 {
46916 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46917 }
46918 }
46919
46920 if(!p_iputw(m->screen_midi,f))
46921 {
46922 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46923 }
46924
46925 if(!p_putc(m->lens_layer,f))
46926 {
46927 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46928 }
46929
46930 for(int32_t k=0; k<32; k++)
46931 {
46932
46933 if(!p_iputw(m->ffcs[k].getData(),f))
46934 {
46935 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46936 }
46937
46938 if(!p_putc(m->ffcs[k].cset,f))
46939 {
46940 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46941 }
46942
46943 if(!p_iputw(m->ffcs[k].delay,f))
46944 {
46945 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46946 }
46947
46948 if(!p_iputzf(m->ffcs[k].x,f))
46949 {
46950 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46951 }
46952
46953 if(!p_iputzf(m->ffcs[k].y,f))
46954 {
46955 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46956 }
46957
46958 if(!p_iputzf(m->ffcs[k].vx,f))
46959 {
46960 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46961 }
46962
46963 if(!p_iputzf(m->ffcs[k].vy,f))
46964 {
46965 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46966 }
46967
46968 if(!p_iputzf(m->ffcs[k].ax,f))
46969 {
46970 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46971 }
46972
46973 if(!p_iputzf(m->ffcs[k].ay,f))
46974 {
46975 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46976 }
46977
46978 if(!p_putc(m->ffcs[k].link,f))
46979 {
46980 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46981 }
46982
46983 if(!p_iputl(m->ffcs[k].hit_width,f))
46984 {
46985 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46986 }
46987
46988 if(!p_iputl(m->ffcs[k].hit_height,f))
46989 {
46990 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46991 }
46992
46993 if(!p_putc(m->ffcs[k].txsz,f))
46994 {
46995 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46996 }
46997
46998 if(!p_putc(m->ffcs[k].tysz,f))
46999 {
47000 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47001 }
47002
47003 if(!p_iputl(m->ffcs[k].flags,f))
47004 {
47005 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47006 }
47007
47008 if(!p_iputw(m->ffcs[k].script,f))
47009 {
47010 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47011 }
47012
47013 if(!p_iputl(m->ffcs[k].initd[0],f))
47014 {
47015 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47016 }
47017
47018 if(!p_iputl(m->ffcs[k].initd[1],f))
47019 {
47020 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47021 }
47022
47023 if(!p_iputl(m->ffcs[k].initd[2],f))
47024 {
47025 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47026 }
47027
47028 if(!p_iputl(m->ffcs[k].initd[3],f))
47029 {
47030 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47031 }
47032
47033 if(!p_iputl(m->ffcs[k].initd[4],f))
47034 {
47035 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47036 }
47037
47038 if(!p_iputl(m->ffcs[k].initd[5],f))
47039 {
47040 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47041 }
47042
47043 if(!p_iputl(m->ffcs[k].initd[6],f))
47044 {
47045 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47046 }
47047
47048 if(!p_iputl(m->ffcs[k].initd[7],f))
47049 {
47050 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47051 }
47052
47053 }
47054
47055 for ( int32_t q = 0; q < 10; q++ )
47056 {
47057 if(!p_iputl(m->npcstrings[q],f))
47058 {
47059 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47060 }
47061 }
47062 for ( int32_t q = 0; q < 10; q++ )
47063 {
47064 if(!p_iputw(m->new_items[q],f))
47065 {
47066 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47067 }
47068 }
47069 for ( int32_t q = 0; q < 10; q++ )
47070 {
47071 if(!p_iputw(m->new_item_x[q],f))
47072 {
47073 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47074 }
47075 }
47076 for ( int32_t q = 0; q < 10; q++ )
47077 {
47078 if(!p_iputw(m->new_item_y[q],f))
47079 {
47080 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47081 }
47082 }
47083 if(!p_iputw(m->script,f))
47084 {
47085 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47086 }
47087 for ( int32_t q = 0; q < 8; q++ )
47088 {
47089 if(!p_iputl(m->screeninitd[q],f))
47090 {
47091 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47092 }
47093
47094 }
47095 if(!p_putc(m->preloadscript,f))
47096 {
47097 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47098 }
47099
47100 if(!p_putc(m->hidelayers,f))
47101 {
47102 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47103 }
47104 if(!p_putc(m->hidescriptlayers,f))
47105 {
47106 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47107 }
47108
47109
47110 } //end mapscr for loop
47111 }
47112 }
47113 void FFScript::read_mapscreens(PACKFILE *f,int32_t vers_id)
47114 {
47115 for(int32_t i=0; i<map_count && i<MAXMAPS2; i++)
47116 {
47117 for(int32_t j=0; j<MAPSCRS; j++)
47118 {
47119 mapscr *m = &TheMaps[i*MAPSCRS+j];
47120
47121 if(!p_getc(&(m->valid),f))
47122 {
47123 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47124 }
47125
47126 if(!p_getc(&(m->guy),f))
47127 {
47128 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47129 }
47130
47131 {
47132 if(!p_igetw(&(m->str),f))
47133 {
47134 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47135 }
47136 }
47137
47138 if(!p_getc(&(m->room),f))
47139 {
47140 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47141 }
47142
47143 if(!p_getc(&(m->item),f))
47144 {
47145 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47146 }
47147
47148 if(!p_getc(&(m->hasitem), f))
47149 {
47150 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47151 }
47152
47153 for(int32_t k=0; k<4; k++)
47154 {
47155 if(!p_getc(&(m->tilewarptype[k]),f))
47156 {
47157 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47158 }
47159 }
47160
47161 if(!p_igetw(&(m->door_combo_set),f))
47162 {
47163 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47164 }
47165
47166 for(int32_t k=0; k<4; k++)
47167 {
47168 if(!p_getc(&(m->warpreturnx[k]),f))
47169 {
47170 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47171 }
47172 }
47173
47174 for(int32_t k=0; k<4; k++)
47175 {
47176 if(!p_getc(&(m->warpreturny[k]),f))
47177 {
47178 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47179 }
47180 }
47181
47182 if(!p_igetw(&(m->warpreturnc),f))
47183 {
47184 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47185 }
47186
47187 if(!p_getc(&(m->stairx),f))
47188 {
47189 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47190 }
47191
47192 if(!p_getc(&(m->stairy),f))
47193 {
47194 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47195 }
47196
47197 if(!p_getc(&(m->itemx),f))
47198 {
47199 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47200 }
47201
47202 if(!p_getc(&(m->itemy),f))
47203 {
47204 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47205 }
47206
47207 if(!p_igetw(&(m->color),f))
47208 {
47209 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47210 }
47211
47212 if(!p_getc(&(m->enemyflags),f))
47213 {
47214 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47215 }
47216
47217 for(int32_t k=0; k<4; k++)
47218 {
47219 if(!p_getc(&(m->door[k]),f))
47220 {
47221 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47222 }
47223 }
47224
47225 for(int32_t k=0; k<4; k++)
47226 {
47227 if(!p_igetw(&(m->tilewarpdmap[k]),f))
47228 {
47229 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47230 }
47231 }
47232
47233 for(int32_t k=0; k<4; k++)
47234 {
47235 if(!p_getc(&(m->tilewarpscr[k]),f))
47236 {
47237 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47238 }
47239 }
47240
47241 if(!p_getc(&(m->tilewarpoverlayflags),f))
47242 {
47243 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47244 }
47245
47246 if(!p_getc(&(m->exitdir),f))
47247 {
47248 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47249 }
47250
47251 for(int32_t k=0; k<10; k++)
47252 {
47253 {
47254 if(!p_igetw(&(m->enemy[k]),f))
47255 {
47256 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47257 }
47258 }
47259 }
47260
47261 if(!p_getc(&(m->pattern),f))
47262 {
47263 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47264 }
47265
47266 for(int32_t k=0; k<4; k++)
47267 {
47268 if(!p_getc(&(m->sidewarptype[k]),f))
47269 {
47270 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47271 }
47272 }
47273
47274 if(!p_getc(&(m->sidewarpoverlayflags),f))
47275 {
47276 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47277 }
47278
47279 if(!p_getc(&(m->warparrivalx),f))
47280 {
47281 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47282 }
47283
47284 if(!p_getc(&(m->warparrivaly),f))
47285 {
47286 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47287 }
47288
47289 for(int32_t k=0; k<4; k++)
47290 {
47291 if(!p_getc(&(m->path[k]),f))
47292 {
47293 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47294 }
47295 }
47296
47297 for(int32_t k=0; k<4; k++)
47298 {
47299 if(!p_getc(&(m->sidewarpscr[k]),f))
47300 {
47301 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47302 }
47303 }
47304
47305 for(int32_t k=0; k<4; k++)
47306 {
47307 if(!p_igetw(&(m->sidewarpdmap[k]),f))
47308 {
47309 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47310 }
47311 }
47312
47313 if(!p_getc(&(m->sidewarpindex),f))
47314 {
47315 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47316 }
47317
47318 if(!p_igetw(&(m->undercombo),f))
47319 {
47320 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47321 }
47322
47323 if(!p_getc(&(m->undercset),f))
47324 {
47325 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47326 }
47327
47328 if(!p_igetw(&(m->catchall),f))
47329 {
47330 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47331 }
47332
47333 if(!p_getc(&(m->flags),f))
47334 {
47335 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47336 }
47337
47338 if(!p_getc(&(m->flags2),f))
47339 {
47340 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47341 }
47342
47343 if(!p_getc(&(m->flags3),f))
47344 {
47345 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47346 }
47347
47348 if(!p_getc(&(m->flags4),f))
47349 {
47350 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47351 }
47352
47353 if(!p_getc(&(m->flags5),f))
47354 {
47355 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47356 }
47357
47358 if(!p_igetw(&(m->noreset),f))
47359 {
47360 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47361 }
47362
47363 if(!p_igetw(&(m->nocarry),f))
47364 {
47365 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47366 }
47367
47368 if(!p_getc(&(m->flags6),f))
47369 {
47370 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47371 }
47372
47373 if(!p_getc(&(m->flags7),f))
47374 {
47375 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47376 }
47377
47378 if(!p_getc(&(m->flags8),f))
47379 {
47380 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47381 }
47382
47383 if(!p_getc(&(m->flags9),f))
47384 {
47385 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47386 }
47387
47388 if(!p_getc(&(m->flags10),f))
47389 {
47390 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47391 }
47392
47393 if(!p_getc(&(m->csensitive),f))
47394 {
47395 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47396 }
47397
47398 if(!p_getc(&(m->oceansfx),f))
47399 {
47400 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47401 }
47402
47403 if(!p_getc(&(m->bosssfx),f))
47404 {
47405 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47406 }
47407
47408 if(!p_getc(&(m->secretsfx),f))
47409 {
47410 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47411 }
47412
47413 if(!p_getc(&(m->holdupsfx),f))
47414 {
47415 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47416 }
47417
47418 for(int32_t k=0; k<6; k++)
47419 {
47420 if(!p_getc(&(m->layermap[k]),f))
47421 {
47422 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47423 }
47424 }
47425
47426 for(int32_t k=0; k<6; k++)
47427 {
47428 if(!p_getc(&(m->layerscreen[k]),f))
47429 {
47430 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47431 }
47432 }
47433
47434 for(int32_t k=0; k<6; k++)
47435 {
47436 if(!p_getc(&(m->layeropacity[k]),f))
47437 {
47438 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47439 }
47440 }
47441
47442 if(!p_igetw(&(m->timedwarptics),f))
47443 {
47444 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47445 }
47446
47447 if(!p_getc(&(m->nextmap),f))
47448 {
47449 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47450 }
47451
47452 if(!p_getc(&(m->nextscr),f))
47453 {
47454 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47455 }
47456
47457 for(int32_t k=0; k<128; k++)
47458 {
47459 if(!p_igetw(&(m->secretcombo[k]),f))
47460 {
47461 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47462 }
47463 }
47464
47465 for(int32_t k=0; k<128; k++)
47466 {
47467 if(!p_getc(&(m->secretcset[k]),f))
47468 {
47469 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47470 }
47471 }
47472
47473 for(int32_t k=0; k<128; k++)
47474 {
47475 if(!p_getc(&(m->secretflag[k]),f))
47476 {
47477 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47478 }
47479 }
47480
47481 for(int32_t k=0; k<(ZCMaps[i].tileWidth)*(ZCMaps[i].tileHeight); k++)
47482 {
47483 try
47484 {
47485 if(!p_igetw(&(m->data[k]),f))
47486 {
47487 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47488 }
47489 }
47490 catch(std::out_of_range& )
47491 {
47492 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47493 }
47494 }
47495
47496 for(int32_t k=0; k<(ZCMaps[i].tileWidth)*(ZCMaps[i].tileHeight); k++)
47497 {
47498 try
47499 {
47500 if(!p_getc(&(m->sflag[k]),f))
47501 {
47502 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47503 }
47504 }
47505 catch(std::out_of_range& )
47506 {
47507 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47508 }
47509 }
47510
47511 for(int32_t k=0; k<(ZCMaps[i].tileWidth)*(ZCMaps[i].tileHeight); k++)
47512 {
47513 try
47514 {
47515 if(!p_getc(&(m->cset[k]),f))
47516 {
47517 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47518 }
47519 }
47520 catch(std::out_of_range& )
47521 {
47522 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47523 }
47524 }
47525
47526 if(!p_igetw(&(m->screen_midi),f))
47527 {
47528 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47529 }
47530
47531 if(!p_getc(&(m->lens_layer),f))
47532 {
47533 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47534 }
47535 word tempw;
47536 for(int32_t k=0; k<32; k++)
47537 {
47538
47539 if(!p_igetw(&tempw,f))
47540 {
47541 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47542 }
47543 m->ffcs[k].setData(tempw);
47544
47545 if(!p_getc(&(m->ffcs[k].cset),f))
47546 {
47547 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47548 }
47549
47550 if(!p_igetw(&(m->ffcs[k].delay),f))
47551 {
47552 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47553 }
47554
47555 if(!p_igetzf(&(m->ffcs[k].x),f))
47556 {
47557 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47558 }
47559
47560 if(!p_igetzf(&(m->ffcs[k].y),f))
47561 {
47562 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47563 }
47564
47565 if(!p_igetzf(&(m->ffcs[k].vx),f))
47566 {
47567 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47568 }
47569
47570 if(!p_igetzf(&(m->ffcs[k].vy),f))
47571 {
47572 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47573 }
47574
47575 if(!p_igetzf(&(m->ffcs[k].ax),f))
47576 {
47577 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47578 }
47579
47580 if(!p_igetzf(&(m->ffcs[k].ay),f))
47581 {
47582 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47583 }
47584
47585 if(!p_getc(&(m->ffcs[k].link),f))
47586 {
47587 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47588 }
47589
47590 if(!p_igetl(&(m->ffcs[k].hit_width),f))
47591 {
47592 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47593 }
47594
47595 if(!p_igetl(&(m->ffcs[k].hit_height),f))
47596 {
47597 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47598 }
47599
47600 if(!p_getc(&(m->ffcs[k].txsz),f))
47601 {
47602 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47603 }
47604
47605 if(!p_getc(&(m->ffcs[k].tysz),f))
47606 {
47607 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47608 }
47609
47610 if(!p_igetl(&(m->ffcs[k].flags),f))
47611 {
47612 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47613 }
47614
47615 if(!p_igetw(&(m->ffcs[k].script),f))
47616 {
47617 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47618 }
47619
47620 if(!p_igetl(&(m->ffcs[k].initd[0]),f))
47621 {
47622 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47623 }
47624
47625 if(!p_igetl(&(m->ffcs[k].initd[1]),f))
47626 {
47627 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47628 }
47629
47630 if(!p_igetl(&(m->ffcs[k].initd[2]),f))
47631 {
47632 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47633 }
47634
47635 if(!p_igetl(&(m->ffcs[k].initd[3]),f))
47636 {
47637 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47638 }
47639
47640 if(!p_igetl(&(m->ffcs[k].initd[4]),f))
47641 {
47642 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47643 }
47644
47645 if(!p_igetl(&(m->ffcs[k].initd[5]),f))
47646 {
47647 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47648 }
47649
47650 if(!p_igetl(&(m->ffcs[k].initd[6]),f))
47651 {
47652 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47653 }
47654
47655 if(!p_igetl(&(m->ffcs[k].initd[7]),f))
47656 {
47657 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47658 }
47659
47660 }
47661
47662 for ( int32_t q = 0; q < 10; q++ )
47663 {
47664 if(!p_igetl(&(m->npcstrings[q]),f))
47665 {
47666 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47667 }
47668 }
47669 for ( int32_t q = 0; q < 10; q++ )
47670 {
47671 if(!p_igetw(&(m->new_items[q]),f))
47672 {
47673 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47674 }
47675 }
47676 for ( int32_t q = 0; q < 10; q++ )
47677 {
47678 if(!p_igetw(&(m->new_item_x[q]),f))
47679 {
47680 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47681 }
47682 }
47683 for ( int32_t q = 0; q < 10; q++ )
47684 {
47685 if(!p_igetw(&(m->new_item_y[q]),f))
47686 {
47687 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47688 }
47689 }
47690 if(!p_igetw(&(m->script),f))
47691 {
47692 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47693 }
47694 for ( int32_t q = 0; q < 8; q++ )
47695 {
47696 if(!p_igetl(&(m->screeninitd[q]),f))
47697 {
47698 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47699 }
47700
47701 }
47702 if(!p_getc(&(m->preloadscript),f))
47703 {
47704 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47705 }
47706
47707 if ( vers_id >= 2 )
47708 {
47709 if(!p_getc(&(m->hidelayers),f))
47710 {
47711 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47712 }
47713 if(!p_getc(&(m->hidescriptlayers),f))
47714 {
47715 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47716 }
47717
47718 }
47719
47720
47721 }//end mapscr all for loop
47722
47723 }
47724 }
47725 /*
47726 void FFScript::write_maps(PACKFILE *f, int32_t vers_id)
47727 {
47728 for(int32_t i=0; i<map_count && i<MAXMAPS2; i++)
47729 {
47730 for(int32_t j=0; j<MAPSCRS; j++)
47731 {
47732 if ( !(FFCore.write_mapscreen(f,i,j,vers_id)) )
47733 {
47734 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODE: %d",i*j);
47735 }
47736 }
47737 }
47738 }
47739
47740 void FFScript::read_maps(PACKFILE *f, int32_t vers_id)
47741 {
47742 for(int32_t i=0; i<map_count && i<MAXMAPS2; i++)
47743 {
47744 for(int32_t j=0; j<MAPSCRS; j++)
47745 {
47746 if ( !(FFCore.read_mapscreen(f,i,j,vers_id)) )
47747 {
47748 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE: %d",i*j);
47749 }
47750 }
47751 }
47752 }
47753 */
47754
47755
47756 int32_t FFScript::getHeroOTile(int32_t index1, int32_t index2)
47757 {
47758 {
47759 herospritetype lst = (herospritetype)index1;
47760 int32_t dir = index2;
47761 int32_t the_ret = 0;
47762 switch(lst)
47763 {
47764 case LSprwalkspr: the_ret = walkspr[dir][0]; break;
47765 case LSprstabspr: the_ret = stabspr[dir][0]; break;
47766 case LSprslashspr: the_ret = slashspr[dir][0]; break;
47767 case LSprrevslashspr: the_ret = revslashspr[dir][0]; break;
47768 case LSprfloatspr: the_ret = floatspr[dir][0]; break;
47769 case LSprswimspr: the_ret = swimspr[dir][0]; break;
47770 case LSprdivespr: the_ret = divespr[dir][0]; break;
47771 case LSprdrownspr: the_ret = drowningspr[dir][0]; break;
47772 case LSprsidedrownspr: the_ret = sidedrowningspr[dir][0]; break;
47773 case LSprlavadrownspr: the_ret = drowning_lavaspr[dir][0]; break;
47774 case LSprsideswimspr: the_ret = sideswimspr[dir][0]; break;
47775 case LSprsideswimslashspr: the_ret = sideswimslashspr[dir][0]; break;
47776 case LSprsideswimstabspr: the_ret = sideswimstabspr[dir][0]; break;
47777 case LSprsideswimpoundspr: the_ret = sideswimpoundspr[dir][0]; break;
47778 case LSprsideswimchargespr: the_ret = sideswimchargespr[dir][0]; break;
47779 case LSprpoundspr: the_ret = poundspr[dir][0]; break;
47780 case LSprjumpspr: the_ret = jumpspr[dir][0]; break;
47781 case LSprchargespr: the_ret = chargespr[dir][0]; break;
47782 case LSprcastingspr: the_ret = castingspr[0]; break;
47783 case LSprsideswimcastingspr: the_ret = sideswimcastingspr[0]; break;
47784 case LSprholdspr1: the_ret = holdspr[0][0][0]; break;
47785 case LSprholdspr2: the_ret = holdspr[0][1][0]; break;
47786 case LSprholdsprw1: the_ret = holdspr[1][0][0]; break;
47787 case LSprholdsprw2: the_ret = holdspr[1][1][0]; break;
47788 case LSprholdsprSw1: the_ret = sideswimholdspr[0][0]; break;
47789 case LSprholdsprSw2: the_ret = sideswimholdspr[1][0]; break;
47790 default: the_ret = 0;
47791 }
47792
47793 return the_ret*10000;
47794 }
47795 }
47796
47797 defWpnSprite FFScript::getDefWeaponSprite(int32_t wpnid)
47798 {
47799 switch(wpnid)
47800 {
47801 case wNone: return ws_0;
47802 case wSword: return ws_0;
47803 case wBeam: return wsBeam;
47804 case wBrang : return wsBrang;
47805 case wBomb: return wsBomb;
47806 case wSBomb: return wsSBomb;
47807 case wLitBomb: return wsBombblast;
47808 case wLitSBomb: return wsBombblast;
47809 case wArrow: return wsArrow;
47810 case wFire: return wsFire;
47811 case wWhistle: return wsUnused45;
47812 case wBait: return wsBait;
47813 case wWand: return wsWandHandle;
47814 case wMagic: return wsMagic;
47815 case wCatching: return wsUnused45;
47816 case wWind: return wsWind;
47817 case wRefMagic: return wsRefMagic;
47818 case wRefFireball: return wsRefFireball;
47819 case wRefRock: return wsRock;
47820 case wHammer: return wsHammer;
47821 case wHookshot: return wsHookshotHead;
47822 case wHSHandle: return wsHookshotHandle;
47823 case wHSChain: return wsHookshotChainH;
47824 case wSSparkle: return wsSilverSparkle;
47825 case wFSparkle: return wsGoldSparkle;
47826 case wSmack: return wsHammerSmack;
47827 case wPhantom: return wsUnused45;
47828 case wCByrna: return wsByrnaCane;
47829 case wRefBeam: return wsRefBeam;
47830 case wStomp: return wsUnused45;
47831 case lwMax: return wsUnused45;
47832 case wScript1:
47833 case wScript2:
47834 case wScript3:
47835 case wScript4:
47836 case wScript5:
47837 case wScript6:
47838 case wScript7:
47839 case wScript8:
47840 case wScript9:
47841 case wScript10: return ws_0;
47842 case wIce: return wsIce; //new
47843 case wFlame: return wsEFire2; //new
47844 //not implemented; t/b/a
47845 case wSound:
47846 case wThrown:
47847 case wPot:
47848 case wLit:
47849 case wBombos:
47850 case wEther:
47851 case wQuake:
47852 case wSword180:
47853 case wSwordLA: return wsUnused45;
47854
47855 case ewFireball: return wsFireball2;
47856 case ewArrow: return wsEArrow;
47857 case ewBrang: return wsBrang;
47858 case ewSword: return wsEBeam;
47859 case ewRock: return wsRock;
47860 case ewMagic: return wsEMagic;
47861 case ewBomb: return wsEBomb;
47862 case ewSBomb: return wsESbomb;
47863 case ewLitBomb: return wsEBombblast;
47864 case ewLitSBomb: return wsESbombblast;
47865 case ewFireTrail: return wsEFiretrail;
47866 case ewFlame: return wsEFire;
47867 case ewWind: return wsEWind;
47868 case ewFlame2: return wsEFire2;
47869 case ewFlame2Trail: return wsEFiretrail2;
47870 case ewIce: return wsIce;
47871 case ewFireball2: return wsFireball2;
47872 default: return wsUnused45;
47873 }
47874 };
47875
47876
47877 12 int32_t FFScript::getEnemyByScriptUID(int32_t sUID)
47878 {
47879
47880
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 for(word i = 0; i < guys.Count(); i++)
47881 {
47882 27 enemy *w = (enemy*)guys.spr(i);
47883
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 15 times.
27 if ( w ->script_UID == sUID ) return i;
47884 15 }
47885 return -1;
47886 12 }
47887
47888 598 int32_t FFScript::getLWeaponByScriptUID(int32_t sUID)
47889 {
47890
47891
1/2
✓ Branch 0 taken 2168 times.
✗ Branch 1 not taken.
2168 for(word i = 0; i < Lwpns.Count(); i++)
47892 {
47893 2168 weapon *w = (weapon*)Lwpns.spr(i);
47894
2/2
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 1570 times.
2168 if ( w ->script_UID == sUID ) return i;
47895 1570 }
47896 return -1;
47897 598 }
47898
47899 int32_t FFScript::getEWeaponByScriptUID(int32_t sUID)
47900 {
47901
47902 for(word i = 0; i < Ewpns.Count(); i++)
47903 {
47904 weapon *w = (weapon*)Ewpns.spr(i);
47905 if ( w ->script_UID == sUID ) return i;
47906 }
47907 return -1;
47908 }
47909
47910
47911 598 void FFScript::do_loadlweapon_by_script_uid(const bool v)
47912 {
47913 598 int32_t sUID = SH::get_arg(sarg1, v); //literal, not div by 10000
47914
47915 598 int32_t indx = FFCore.getLWeaponByScriptUID(sUID);
47916
1/2
✓ Branch 0 taken 598 times.
✗ Branch 1 not taken.
598 if ( indx > -1 )
47917 598 ri->lwpn = Lwpns.spr(indx)->getUID();
47918 else
47919 {
47920 ri->lwpn = 0;
47921 if(get_qr(qr_LOG_INVALID_UID_LOAD))
47922 Z_scripterrlog("There is no valid LWeapon associated with UID (%) at this time.\nThe UID is stale, or invalid.\n", sUID);
47923 }
47924 598 }
47925
47926 void FFScript::do_loadeweapon_by_script_uid(const bool v)
47927 {
47928
47929 int32_t sUID = SH::get_arg(sarg1, v); //literal, not div by 10000
47930
47931 int32_t indx = FFCore.getEWeaponByScriptUID(sUID);
47932 if ( indx > -1 )
47933 ri->ewpn = Ewpns.spr(indx)->getUID();
47934 else
47935 {
47936 ri->ewpn = 0;
47937 if(get_qr(qr_LOG_INVALID_UID_LOAD))
47938 Z_scripterrlog("There is no valid EWeapon associated with UID (%) at this time.\nThe UID is stale, or invalid.\n", sUID);
47939 }
47940 }
47941
47942
47943 12 void FFScript::do_loadnpc_by_script_uid(const bool v)
47944 {
47945
47946 12 int32_t sUID = SH::get_arg(sarg1, v); //literal, not div by 10000
47947
47948 12 int32_t indx = FFCore.getEnemyByScriptUID(sUID);
47949
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if ( indx > -1 )
47950 12 ri->guyref = guys.spr(indx)->getUID();
47951 else
47952 {
47953 ri->guyref = 0;
47954 if(get_qr(qr_LOG_INVALID_UID_LOAD))
47955 Z_scripterrlog("There is no valid NPC associated with UID (%) at this time.\nThe UID is stale, or invalid.\n", sUID);
47956 }
47957 12 }
47958
47959 //Combo Scripts
47960
47961 58862 void FFScript::clear_combo_scripts()
47962 {
47963 58862 memset(combo_id_cache, -1, sizeof(combo_id_cache));
47964 58862 clear_script_engine_data_of_type(ScriptType::Combo);
47965 58862 }
47966
47967 3018 void FFScript::clear_combo_script(int32_t lyr, int32_t pos)
47968 {
47969
1/2
✓ Branch 0 taken 3018 times.
✗ Branch 1 not taken.
3018 if(lyr < 0) return;
47970
47971
47972 3018 int32_t index = get_combopos_ref(pos, lyr);
47973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3018 times.
3018 if (index >= 176*7) return;
47974
47975 3018 combo_id_cache[index] = -1;
47976 3018 combopos_modified = index;
47977 3018 clear_script_engine_data(ScriptType::Combo, index);
47978 3018 }
47979
47980 int32_t FFScript::getComboDataLayer(int32_t c, ScriptType scripttype)
47981 {
47982 if ( scripttype != ScriptType::Combo )
47983 {
47984 Z_scripterrlog("combodata->Layer() only runs from combo scripts, not from script type &s\n", ScriptTypeToString(scripttype));
47985 return -1;
47986 }
47987 else
47988 {
47989 int32_t l = 0;
47990 for (int32_t q = 176; q < 1232; q+= 176 )
47991 {
47992 if ( c < q )
47993 {
47994 return l;
47995 }
47996 ++l;
47997 }
47998 return -1;
47999 }
48000 }
48001
48002 int32_t FFScript::getCombodataPos(int32_t c, ScriptType scripttype)
48003 {
48004 if ( scripttype != ScriptType::Combo )
48005 {
48006 Z_scripterrlog("combodata->Pos() only runs from combo scripts, not from script type &s\n", ScriptTypeToString(scripttype));
48007 return -1;
48008 }
48009 else return ((c%176));
48010 }
48011
48012 int32_t FFScript::getCombodataX(int32_t c, ScriptType scripttype)
48013 {
48014 if ( scripttype != ScriptType::Combo )
48015 {
48016 Z_scripterrlog("combodata->X() only runs from combo scripts, not from script type &s\n", ScriptTypeToString(scripttype));
48017 return -1;
48018 }
48019 else
48020 {
48021 int32_t pos = getCombodataPos(c, scripttype);
48022 return COMBOX(pos);
48023 }
48024 }
48025
48026 int32_t FFScript::getCombodataY(int32_t c, ScriptType scripttype)
48027 {
48028 if ( scripttype != ScriptType::Combo )
48029 {
48030 Z_scripterrlog("combodata->Y() only runs from combo scripts, not from script type &s\n", ScriptTypeToString(scripttype));
48031 return -1;
48032 }
48033 else
48034 {
48035 int32_t pos = getCombodataPos(c, scripttype);
48036 return COMBOY(pos);
48037 }
48038 }
48039
48040 void FFScript::ClearComboScripts()
48041 {
48042 for ( int32_t c = 0; c < 176; c++ )
48043 {
48044 reset_script_engine_data(ScriptType::Combo, c);
48045 }
48046 }
48047
48048 628691 int32_t FFScript::combo_script_engine(const bool preload, const bool waitdraw)
48049 {
48050 ///non-scripted effects
48051
2/2
✓ Branch 0 taken 4400837 times.
✓ Branch 1 taken 628691 times.
5029528 for ( int32_t q = 0; q < 7; ++q )
48052 {
48053
2/2
✓ Branch 0 taken 559967 times.
✓ Branch 1 taken 3840870 times.
4400837 if (!get_qr(qr_COMBOSCRIPTS_LAYER_0+q))
48054 3840870 continue;
48055
2/2
✓ Branch 0 taken 98554192 times.
✓ Branch 1 taken 559967 times.
99114159 for ( int32_t c = 0; c < 176; ++c )
48056 {
48057 // int32_t ls = (q ? tmpscr->layerscreen[q-1] : 0);
48058 // int32_t lm = (q ? tmpscr->layermap[q-1] : 0);
48059 // if(q && !lm) continue; //No layer for this screen
48060 98554192 int32_t idval = get_combopos_ref(c, q);
48061 98554192 mapscr* m = FFCore.tempScreens[q]; //get templayer mapscr for any layer (including 0)
48062 98554192 word cid = m->data[c];
48063
1/2
✓ Branch 0 taken 98554192 times.
✗ Branch 1 not taken.
98554192 if(combo_id_cache[idval] < 0)
48064 combo_id_cache[idval] = cid;
48065
2/2
✓ Branch 0 taken 98393297 times.
✓ Branch 1 taken 160895 times.
98554192 else if(combo_id_cache[idval] != cid)
48066 {
48067 160895 combopos_modified = idval;
48068 160895 combo_id_cache[idval] = cid;
48069 160895 clear_script_engine_data(ScriptType::Combo, idval);
48070 160895 }
48071
48072
2/2
✓ Branch 0 taken 98430424 times.
✓ Branch 1 taken 123768 times.
98554192 if ( combobuf[cid].script )
48073 {
48074 123768 auto& data = get_script_engine_data(ScriptType::Combo, idval);
48075
2/2
✓ Branch 0 taken 47615 times.
✓ Branch 1 taken 76153 times.
123768 if (data.doscript)
48076 {
48077
3/4
✓ Branch 0 taken 38064 times.
✓ Branch 1 taken 38089 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38064 times.
76153 if (waitdraw && !data.waitdraw) continue;
48078
48079 38089 ZScriptVersion::RunScript(ScriptType::Combo, combobuf[cid].script, idval);
48080
1/2
✓ Branch 0 taken 38089 times.
✗ Branch 1 not taken.
38089 if (waitdraw) data.waitdraw = false;
48081 38089 }
48082 85704 }
48083 98516128 }
48084 559967 }
48085 628691 return 1;
48086 }
48087
48088 //Config for file->
48089
48090 /* ______ ___ ___
48091 * /\ _ \ /\_ \ /\_ \
48092 * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
48093 * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
48094 * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
48095 * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
48096 * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
48097 * /\____/
48098 * \_/__/
48099 *
48100 * Ported from Allegro 4.4.3.1 Configuration routines.
48101 *
48102 * By Shawn Hargreaves; C++ Port by ZoriaRPG
48103 *
48104 * Hook functions added by Martijn Versteegh.
48105 *
48106 * Annie Testes lifted several hardcoded length limitations.
48107 *
48108 * See readme.txt for copyright information.
48109 */
48110
48111
48112 #include "allegro.h"
48113 #include "allegro/internal/aintern.h"
48114
48115
48116
48117
48118
48119 /* zscript_flush_config:
48120 * Writes out a config structure to disk if the contents
48121 * have changed.
48122 */
48123 void zscript_flush_config(ZSCRIPT_CONFIG *cfg)
48124 {
48125 ZSCRIPT_CONFIG_ENTRY *pos;
48126 PACKFILE *f;
48127 char cr[16];
48128
48129 usetc(cr+usetc(cr, '\n'), 0);
48130
48131 if (cfg && cfg->filename && cfg->dirty)
48132 {
48133 /* write changed data to disk */
48134 f = pack_fopen(cfg->filename, F_WRITE);
48135
48136 if (f)
48137 {
48138 pos = cfg->head;
48139
48140 while (pos)
48141 {
48142 if (pos->name)
48143 {
48144 pack_fputs(pos->name, f);
48145
48146 if (ugetc(pos->name) != '[')
48147 {
48148 pack_putc(' ', f);
48149 pack_putc('=', f);
48150 pack_putc(' ', f);
48151 }
48152 }
48153
48154 if (pos->data)
48155 pack_fputs(pos->data, f);
48156
48157 pack_fputs(cr, f);
48158
48159 pos = pos->next;
48160 }
48161
48162 pack_fclose(f);
48163 cfg->dirty = FALSE;
48164 }
48165 }
48166 }
48167
48168
48169
48170 /* zscript_flush_config_file:
48171 * Writes out the config file to disk if the contents
48172 * have changed.
48173 */
48174 void zscript_flush_config_file(void)
48175 {
48176 zscript_flush_config(config[0]);
48177 }
48178
48179
48180
48181 /* zscript_destroy_config:
48182 * Destroys a config structure, writing it out to disk if the contents
48183 * have changed.
48184 */
48185 void zscript_destroy_config(ZSCRIPT_CONFIG *cfg)
48186 {
48187 ZSCRIPT_CONFIG_ENTRY *pos, *prev;
48188
48189 if (cfg)
48190 {
48191 zscript_flush_config(cfg);
48192
48193 if (cfg->filename)
48194 _AL_FREE(cfg->filename);
48195
48196 /* destroy the variable list */
48197 pos = cfg->head;
48198
48199 while (pos)
48200 {
48201 prev = pos;
48202 pos = pos->next;
48203
48204 if (prev->name)
48205 _AL_FREE(prev->name);
48206
48207 if (prev->data)
48208 _AL_FREE(prev->data);
48209
48210 _AL_FREE(prev);
48211 }
48212
48213 _AL_FREE(cfg);
48214 }
48215 }
48216
48217
48218
48219 /* zscript_config_cleanup:
48220 * Called at shutdown time to free memory being used by the config routines,
48221 * and write any changed data out to disk.
48222 */
48223 void zscript_config_cleanup(void)
48224 {
48225 ZSCRIPT_CONFIG_HOOK *hook, *nexthook;
48226 int32_t i;
48227
48228 for (i=0; i<MAX_CONFIGS; i++)
48229 {
48230 if (config[i])
48231 {
48232 zscript_destroy_config(config[i]);
48233 config[i] = NULL;
48234 }
48235 }
48236
48237 if (config_override)
48238 {
48239 zscript_destroy_config(config_override);
48240 config_override = NULL;
48241 }
48242
48243 if (config_language)
48244 {
48245 zscript_destroy_config(config_language);
48246 config_language = NULL;
48247 }
48248
48249 if (system_config)
48250 {
48251 zscript_destroy_config(system_config);
48252 system_config = NULL;
48253 }
48254
48255 if (config_hook)
48256 {
48257 hook = config_hook;
48258
48259 while (hook)
48260 {
48261 if (hook->section)
48262 _AL_FREE(hook->section);
48263
48264 nexthook = hook->next;
48265 _AL_FREE(hook);
48266 hook = nexthook;
48267 }
48268
48269 config_hook = NULL;
48270 }
48271
48272 _AL_FREE(config_argv);
48273 config_argv = NULL;
48274
48275 _AL_FREE(argv_buf);
48276 argv_buf = NULL;
48277
48278 argv_buf_size = 0;
48279
48280 _remove_exit_func(zscript_config_cleanup);
48281 config_installed = FALSE;
48282 }
48283
48284
48285
48286 /* zscript_init_config:
48287 * Sets up the configuration routines ready for use, also loading the
48288 * default config file if the loaddata flag is set and no other config
48289 * file is in memory.
48290 */
48291 void zscript_init_config(int32_t loaddata)
48292 {
48293 char filename[1024], tmp[128], *cfg_name;
48294
48295 if (!config_installed)
48296 {
48297 _add_exit_func(zscript_config_cleanup, "zscript_config_cleanup");
48298 config_installed = TRUE;
48299 }
48300
48301 if ((loaddata) && (!config[0]))
48302 {
48303 cfg_name = uconvert_ascii("allegro.cfg", tmp);
48304
48305 if (find_allegro_resource(filename, cfg_name, NULL, NULL, NULL, NULL, NULL, sizeof(filename)) != 0)
48306 {
48307 get_executable_name(filename, sizeof(filename));
48308 usetc(get_filename(filename), 0);
48309 ustrzcat(filename, sizeof(filename), cfg_name);
48310 }
48311
48312 zscript_set_config_file(filename);
48313 }
48314
48315 if (!system_config)
48316 {
48317 system_config = (struct ZSCRIPT_CONFIG*)malloc(sizeof(ZSCRIPT_CONFIG));
48318 if (system_config)
48319 {
48320 system_config->head = NULL;
48321 system_config->filename = NULL;
48322 system_config->dirty = FALSE;
48323 }
48324 }
48325 }
48326
48327
48328
48329 /* zscript_get_config_line:
48330 * Helper for splitting files up into individual lines. Returns the length
48331 * in bytes of the sequence of characters delimited by the first EOL marker
48332 * in the array DATA of length LENGTH, and allocates NAME and VAL to record
48333 * the name and the value of the config entry respectively; otherwise set
48334 * NAME to NULL and returns a copy of the line through VAL if the line was
48335 * blank or a comment. Returns -1 and set allegro_errno on failure.
48336 */
48337 int32_t zscript_get_config_line(const char *data, int32_t length, char **name, char **val)
48338 {
48339 char *buf;
48340 int32_t buf_size=256;
48341 int32_t inpos, outpos, i, j;
48342 int32_t c, c2, w0;
48343
48344 inpos = 0;
48345 outpos = 0;
48346 w0 = ucwidth(0);
48347
48348 buf = (char*)_AL_MALLOC_ATOMIC(buf_size);
48349 if (!buf)
48350 {
48351 *allegro_errno = ENOMEM;
48352 return -1;
48353 }
48354
48355 /* search for an EOL marker */
48356 while (inpos<length)
48357 {
48358 c = ugetc(data+inpos);
48359 if ((c == '\r') || (c == '\n'))
48360 {
48361 inpos += uwidth(data+inpos);
48362 if (inpos < length)
48363 {
48364 c2 = ugetc(data+inpos);
48365 if (((c == '\r') && (c2 == '\n')) || ((c == '\n') && (c2 == '\r')))
48366 inpos += uwidth(data+inpos);
48367 }
48368 break;
48369 }
48370
48371 /* increase the buffer size if needed */
48372 if (outpos>=(int32_t)buf_size-w0)
48373 {
48374 buf_size *= 2;
48375 buf = (char*)_al_sane_realloc(buf, buf_size);
48376 if (!buf)
48377 {
48378 *allegro_errno = ENOMEM;
48379 return -1;
48380 }
48381 }
48382
48383 outpos += usetc(buf+outpos, c);
48384 inpos += uwidth(data+inpos);
48385 }
48386
48387 usetc(buf+outpos, 0);
48388
48389 /* skip leading spaces */
48390 i = 0;
48391 c = ugetc(buf);
48392
48393 while ((c) && (uisspace(c)))
48394 {
48395 i += uwidth(buf+i);
48396 c = ugetc(buf+i);
48397 }
48398
48399 /* read name string */
48400 j = 0;
48401
48402 /* compute name length */
48403 while ((c) && (!uisspace(c)) && (c != '=') && (c != '#'))
48404 {
48405 j += ucwidth(c);
48406 i += uwidth(buf+i);
48407 c = ugetc(buf+i);
48408 }
48409
48410 if (j)
48411 {
48412 /* got a variable */
48413 *name = (char*)_AL_MALLOC_ATOMIC(j+w0);
48414 if (!(*name))
48415 {
48416 *allegro_errno = ENOMEM;
48417 _AL_FREE(buf);
48418 return -1;
48419 }
48420
48421 ustrzcpy(*name, j+w0, buf+i-j);
48422
48423 while ((c) && ((uisspace(c)) || (c == '=')))
48424 {
48425 i += uwidth(buf+i);
48426 c = ugetc(buf+i);
48427 }
48428
48429 *val = _al_ustrdup(buf+i);
48430 if (!(*val))
48431 {
48432 _AL_FREE(name);
48433 _AL_FREE(buf);
48434 return -1;
48435 }
48436
48437 /* strip trailing spaces */
48438 i = ustrlen(*val) - 1;
48439 while ((i >= 0) && (uisspace(ugetat(*val, i))))
48440 usetat(*val, i--, 0);
48441 }
48442 else
48443 {
48444 /* blank line or comment */
48445 *name = NULL;
48446 *val = _al_ustrdup(buf);
48447 if (!(*val))
48448 {
48449 _AL_FREE(buf);
48450 return -1;
48451 }
48452 }
48453
48454 _AL_FREE(buf);
48455
48456 return inpos;
48457 }
48458
48459
48460
48461 /* zscript_set_config:
48462 * Does the work of setting up a config structure.
48463 */
48464 void zscript_set_config(ZSCRIPT_CONFIG **config, const char *data, int32_t length, const char *filename)
48465 {
48466 ZSCRIPT_CONFIG_ENTRY **prev, *p;
48467 char *name, *val;
48468 int32_t ret, pos;
48469
48470 zscript_init_config(FALSE);
48471
48472 if (*config)
48473 {
48474 zscript_destroy_config(*config);
48475 *config = NULL;
48476 }
48477
48478 *config = (struct ZSCRIPT_CONFIG*)_AL_MALLOC(sizeof(ZSCRIPT_CONFIG));
48479 if (!(*config))
48480 {
48481 *allegro_errno = ENOMEM;
48482 return;
48483 }
48484
48485 (*config)->head = NULL;
48486 (*config)->dirty = FALSE;
48487
48488 if (filename)
48489 {
48490 (*config)->filename = _al_ustrdup(filename);
48491 if (!(*config)->filename)
48492 {
48493 _AL_FREE(*config);
48494 *config = NULL;
48495 return;
48496 }
48497 }
48498 else
48499 (*config)->filename = NULL;
48500
48501 prev = &(*config)->head;
48502 pos = 0;
48503
48504 while (pos < length)
48505 {
48506 ret = zscript_get_config_line(data+pos, length-pos, &name, &val);
48507 if (ret<0)
48508 {
48509 _AL_FREE(*config);
48510 *config = NULL;
48511 return;
48512 }
48513
48514 pos += ret;
48515
48516 p = (struct ZSCRIPT_CONFIG_ENTRY*)_AL_MALLOC(sizeof(ZSCRIPT_CONFIG_ENTRY));
48517 if (!p)
48518 {
48519 *allegro_errno = ENOMEM;
48520 _AL_FREE(*config);
48521 *config = NULL;
48522 return;
48523 }
48524
48525 p->name = name;
48526 p->data = val;
48527
48528 p->next = NULL;
48529 *prev = p;
48530 prev = &p->next;
48531 }
48532 }
48533
48534
48535
48536 /* zscript_load_config_file:
48537 * Does the work of loading a config file.
48538 */
48539 void zscript_load_config_file(ZSCRIPT_CONFIG **config, const char *filename, const char *savefile)
48540 {
48541 char *tmp, *tmp2;
48542 uint64_t length;
48543
48544 if (*config)
48545 {
48546 zscript_destroy_config(*config);
48547 *config = NULL;
48548 }
48549
48550 /* Special case when allegro_init has not been called yet. */
48551 if (!system_driver)
48552 {
48553 zscript_set_config(config, NULL, 0, savefile);
48554 return;
48555 }
48556
48557 length = file_size_ex(filename);
48558
48559 if (length > 0)
48560 {
48561 PACKFILE *f = pack_fopen(filename, F_READ);
48562
48563 if (f)
48564 {
48565 tmp = (char*)_AL_MALLOC_ATOMIC(length+1);
48566
48567 if (tmp)
48568 {
48569 pack_fread(tmp, length, f);
48570 tmp[length] = 0;
48571
48572 if (need_uconvert(tmp, U_UTF8, U_CURRENT))
48573 {
48574 length = uconvert_size(tmp, U_UTF8, U_CURRENT);
48575 tmp2 = (char*)_AL_MALLOC_ATOMIC(length);
48576
48577 if (tmp2)
48578 do_uconvert(tmp, U_UTF8, tmp2, U_CURRENT, length);
48579
48580 length -= ucwidth(0);
48581 }
48582 else
48583 tmp2 = tmp;
48584
48585 if (tmp2)
48586 {
48587 zscript_set_config(config, tmp2, length, savefile);
48588
48589 if (tmp2 != tmp)
48590 _AL_FREE(tmp2);
48591 }
48592
48593 _AL_FREE(tmp);
48594 }
48595 else
48596 zscript_set_config(config, NULL, 0, savefile);
48597
48598 pack_fclose(f);
48599 }
48600 else
48601 zscript_set_config(config, NULL, 0, savefile);
48602 }
48603 else
48604 zscript_set_config(config, NULL, 0, savefile);
48605 }
48606
48607
48608
48609 /* zscript_set_config_file:
48610 * Sets the file to be used for all future configuration operations.
48611 */
48612 void zscript_set_config_file(const char *filename)
48613 {
48614 ASSERT(filename);
48615 zscript_load_config_file(&config[0], filename, filename);
48616 }
48617
48618
48619
48620 /* zscript_set_config_data:
48621 * Sets the block of data to be used for all future configuration
48622 * operations.
48623 */
48624 void zscript_set_config_data(const char *data, int32_t length)
48625 {
48626 ASSERT(data);
48627 zscript_set_config(&config[0], data, length, NULL);
48628 }
48629
48630
48631
48632 /* zscript_override_config_file:
48633 * Sets the file that will override all future configuration operations.
48634 */
48635 void zscript_override_config_file(const char *filename)
48636 {
48637 /* load other configuration file to override settings */
48638 if (filename)
48639 zscript_load_config_file(&config_override, filename, filename);
48640 /* destroy the current one */
48641 else if (config_override)
48642 {
48643 zscript_destroy_config(config_override);
48644 config_override = NULL;
48645 }
48646 }
48647
48648
48649
48650 /* zscript_override_config_data:
48651 * Sets the block of data that will override all future configuration
48652 * operations.
48653 */
48654 void zscript_override_config_data(const char *data, int32_t length)
48655 {
48656 ASSERT(data);
48657 zscript_set_config(&config_override, data, length, NULL);
48658 }
48659
48660
48661
48662 /* zscript_push_config_state:
48663 * Pushes the current config state onto the stack.
48664 */
48665 void zscript_push_config_state(void)
48666 {
48667 int32_t i;
48668
48669 if (config[MAX_CONFIGS-1])
48670 zscript_destroy_config(config[MAX_CONFIGS-1]);
48671
48672 for (i=MAX_CONFIGS-1; i>0; i--)
48673 config[i] = config[i-1];
48674
48675 config[0] = NULL;
48676 }
48677
48678
48679
48680 /* zscript_pop_config_state:
48681 * Pops the current config state off the stack.
48682 */
48683 void zscript_pop_config_state(void)
48684 {
48685 int32_t i;
48686
48687 if (config[0])
48688 zscript_destroy_config(config[0]);
48689
48690 for (i=0; i<MAX_CONFIGS-1; i++)
48691 config[i] = config[i+1];
48692
48693 config[MAX_CONFIGS-1] = NULL;
48694 }
48695
48696
48697
48698 /* zscript_prettify_config_section_name:
48699 * Helper for ensuring that a section name is enclosed by [ ] braces.
48700 */
48701 void zscript_prettify_config_section_name(const char *in, char *out, int32_t out_size)
48702 {
48703 int32_t p;
48704
48705 if ((in) && (ustrlen(in)))
48706 {
48707 if (ugetc(in) != '[')
48708 {
48709 p = usetc(out, '[');
48710 usetc(out+p, 0);
48711 }
48712 else
48713 usetc(out, 0);
48714
48715 ustrzcat(out, out_size - ucwidth(']'), in);
48716
48717 out += uoffset(out, -1);
48718
48719 if (ugetc(out) != ']')
48720 {
48721 out += uwidth(out);
48722 out += usetc(out, ']');
48723 usetc(out, 0);
48724 }
48725 }
48726 else
48727 usetc(out, 0);
48728 }
48729
48730
48731
48732 /* zscript_hook_config_section:
48733 * Hooks a config section to a set of getter/setter functions. This will
48734 * override the normal table of values, and give the provider of the hooks
48735 * complete control over that section.
48736 */
48737 void zscript_hook_config_section(const char *section, int32_t (*intgetter)(const char *, int32_t), const char *(*stringgetter)(const char *, const char *), void (*stringsetter)(const char *, const char *))
48738 {
48739 ZSCRIPT_CONFIG_HOOK *hook, **prev;
48740 char section_name[256];
48741
48742 zscript_init_config(FALSE);
48743
48744 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
48745
48746 hook = config_hook;
48747 prev = &config_hook;
48748
48749 while (hook)
48750 {
48751 if (ustricmp(section_name, hook->section) == 0)
48752 {
48753 if ((intgetter) || (stringgetter) || (stringsetter))
48754 {
48755 /* modify existing hook */
48756 hook->intgetter = intgetter;
48757 hook->stringgetter = stringgetter;
48758 hook->stringsetter = stringsetter;
48759 }
48760 else
48761 {
48762 /* remove a hook */
48763 *prev = hook->next;
48764 _AL_FREE(hook->section);
48765 }
48766
48767 return;
48768 }
48769
48770 prev = &hook->next;
48771 hook = hook->next;
48772 }
48773
48774 /* add a new hook */
48775 hook = (struct ZSCRIPT_CONFIG_HOOK*)_AL_MALLOC(sizeof(ZSCRIPT_CONFIG_HOOK));
48776 if (!hook)
48777 return;
48778
48779 hook->section = _al_ustrdup(section_name);
48780 if (!(hook->section))
48781 {
48782 _AL_FREE(hook);
48783 return;
48784 }
48785
48786 hook->intgetter = intgetter;
48787 hook->stringgetter = stringgetter;
48788 hook->stringsetter = stringsetter;
48789
48790 hook->next = config_hook;
48791 config_hook = hook;
48792 }
48793
48794
48795
48796 /* is_config_hooked:
48797 * Checks whether a specific section is hooked in any way.
48798 */
48799 int32_t zscript_config_is_hooked(const char *section)
48800 {
48801 ZSCRIPT_CONFIG_HOOK *hook = config_hook;
48802 char section_name[256];
48803
48804 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
48805
48806 while (hook)
48807 {
48808 if (ustricmp(section_name, hook->section) == 0)
48809 return TRUE;
48810
48811 hook = hook->next;
48812 }
48813
48814 return FALSE;
48815 }
48816
48817
48818
48819 /* zscript_find_config_string:
48820 * Helper for finding an entry in the configuration file.
48821 */
48822 ZSCRIPT_CONFIG_ENTRY *zscript_find_config_string(ZSCRIPT_CONFIG *config, const char *section, const char *name, ZSCRIPT_CONFIG_ENTRY **prev)
48823 {
48824 ZSCRIPT_CONFIG_ENTRY *p;
48825 int32_t in_section;
48826
48827 if (config)
48828 {
48829 p = config->head;
48830
48831 if (prev)
48832 *prev = NULL;
48833
48834 if (section && ugetc(section))
48835 in_section = FALSE;
48836 else
48837 in_section = TRUE;
48838
48839 while (p)
48840 {
48841 if (p->name)
48842 {
48843 if ((section) && (ugetc(p->name) == '[') && (ugetat(p->name, -1) == ']'))
48844 {
48845 /* change section */
48846 in_section = (ustricmp(section, p->name) == 0);
48847 }
48848 if ((in_section) || (ugetc(name) == '['))
48849 {
48850 /* is this the one? */
48851 if (ustricmp(p->name, name) == 0)
48852 return p;
48853 }
48854 }
48855
48856 if (prev)
48857 *prev = p;
48858
48859 p = p->next;
48860 }
48861 }
48862
48863 return NULL;
48864 }
48865
48866
48867
48868 /* zscript_get_config_string:
48869 * Reads a string from the configuration file.
48870 */
48871 const char *zscript_get_config_string(const char *section, const char *name, const char *def)
48872 {
48873 char section_name[256];
48874 ZSCRIPT_CONFIG_HOOK *hook;
48875 ZSCRIPT_CONFIG_ENTRY *p;
48876
48877 zscript_init_config(TRUE);
48878
48879 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
48880
48881 /* check for hooked sections */
48882 hook = config_hook;
48883
48884 while (hook)
48885 {
48886 if (ustricmp(section_name, hook->section) == 0)
48887 {
48888 if (hook->stringgetter)
48889 return hook->stringgetter(name, def);
48890 else
48891 return def;
48892 }
48893 hook = hook->next;
48894 }
48895
48896 /* find the string */
48897 p = zscript_find_config_string(config_override, section_name, name, NULL);
48898
48899 if (!p)
48900 {
48901 if ((ugetc(name) == '#') || ((ugetc(section_name) == '[') && (ugetat(section_name, 1) == '#')))
48902 p = zscript_find_config_string(system_config, section_name, name, NULL);
48903 else
48904 p = zscript_find_config_string(config[0], section_name, name, NULL);
48905 }
48906
48907 if (p && p->data && (ustrlen(p->data) != 0))
48908 return p->data;
48909 else
48910 return def;
48911 }
48912
48913
48914
48915 /* zscript_get_config_int:
48916 * Reads an integer from the configuration file.
48917 */
48918 int32_t zscript_get_config_int(const char *section, const char *name, int32_t def)
48919 {
48920 ZSCRIPT_CONFIG_HOOK *hook;
48921 char section_name[256];
48922 const char *s;
48923
48924 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
48925
48926 /* check for hooked sections */
48927 hook = config_hook;
48928
48929 while (hook)
48930 {
48931 if (ustricmp(section_name, hook->section) == 0)
48932 {
48933 if (hook->intgetter)
48934 {
48935 return hook->intgetter(name, def);
48936 }
48937 else if (hook->stringgetter)
48938 {
48939 s = hook->stringgetter(name, NULL);
48940 if ((s) && (ugetc(s)))
48941 return ustrtol(s, NULL, 0);
48942 else
48943 return def;
48944 }
48945 else
48946 return def;
48947 }
48948 hook = hook->next;
48949 }
48950
48951 /* read normal data */
48952 s = zscript_get_config_string(section_name, name, NULL);
48953
48954 if ((s) && (ugetc(s)))
48955 return ustrtol(s, NULL, 0);
48956
48957 return def;
48958 }
48959
48960
48961
48962 /* zscript_get_config_hex:
48963 * Reads a hexadecimal integer from the configuration file.
48964 */
48965 int32_t zscript_get_config_hex(const char *section, const char *name, int32_t def)
48966 {
48967 const char *s = zscript_get_config_string(section, name, NULL);
48968 char tmp[64];
48969 int32_t i;
48970
48971 if ((s) && (ugetc(s)))
48972 {
48973 i = ustrtol(s, NULL, 16);
48974 if ((i == 0x7FFFFFFF) && (ustricmp(s, uconvert_ascii("7FFFFFFF", tmp)) != 0))
48975 i = -1;
48976 return i;
48977 }
48978
48979 return def;
48980 }
48981
48982
48983
48984 /* zscript_get_config_float:
48985 * Reads a float from the configuration file.
48986 */
48987 float zscript_get_config_float(const char *section, const char *name, float def)
48988 {
48989 const char* s = zscript_get_config_string(section, name, NULL);
48990
48991 if ((s) && (ugetc(s)))
48992 return uatof(s);
48993
48994 return def;
48995 }
48996
48997
48998
48999 /* zscript_get_config_id:
49000 * Reads a driver ID number from the configuration file.
49001 */
49002 int32_t zscript_get_config_id(const char *section, const char *name, int32_t def)
49003 {
49004 const char *s = zscript_get_config_string(section, name, NULL);
49005 char tmp[4];
49006 char* endp;
49007 int32_t val, i;
49008
49009 if ((s) && (ugetc(s)))
49010 {
49011 val = ustrtol(s, &endp, 0);
49012 if (!ugetc(endp))
49013 return val;
49014
49015 tmp[0] = tmp[1] = tmp[2] = tmp[3] = ' ';
49016
49017 for (i=0; i<4; i++)
49018 {
49019 if (ugetat(s, i))
49020 tmp[i] = utoupper(ugetat(s ,i));
49021 else
49022 break;
49023 }
49024
49025 return AL_ID(tmp[0], tmp[1], tmp[2], tmp[3]);
49026 }
49027
49028 return def;
49029 }
49030
49031
49032
49033 /* zscript_get_config_argv:
49034 * Reads an argc/argv style token list from the configuration file.
49035 */
49036 char **zscript_get_config_argv(const char *section, const char *name, int32_t *argc)
49037 {
49038 int32_t pos, ac, q, c;
49039 int32_t s_size;
49040 int32_t i;
49041
49042 const char *s = zscript_get_config_string(section, name, NULL);
49043
49044 if (!s)
49045 {
49046 *argc = 0;
49047 return NULL;
49048 }
49049
49050 /* clean up the old argv that was allocated the last time this function was
49051 * called.
49052 */
49053 _AL_FREE(config_argv);
49054 config_argv = NULL;
49055
49056 /* increase the buffer size if needed */
49057 s_size = ustrsizez(s);
49058 if (s_size>argv_buf_size)
49059 {
49060 argv_buf_size = s_size;
49061 argv_buf = (char*)_al_sane_realloc(argv_buf, argv_buf_size);
49062 if (!argv_buf)
49063 {
49064 *allegro_errno = ENOMEM;
49065 *argc = 0;
49066 return NULL;
49067 }
49068 }
49069
49070 ustrzcpy(argv_buf, argv_buf_size, s);
49071 pos = 0;
49072 ac = 0;
49073
49074 /* tokenize the buffer and count the number of words; every space character
49075 * as well as single and double quotes are replaced with zeros; comments * that start with # are also cut off with a 0
49076 */
49077 c = ugetc(argv_buf);
49078 while ((c) && (c != '#'))
49079 {
49080 /* replace all spaces up to the next word with 0 */
49081 while ((c) && (uisspace(c)))
49082 {
49083 usetat(argv_buf+pos, 0, 0);
49084 pos += ucwidth(0);
49085 c = ugetc(argv_buf+pos);
49086 }
49087
49088 /* quit if we reached the end of the buffer or a comment */
49089 if ((c) && (c != '#'))
49090 {
49091 /* found another word! */
49092 ac++;
49093
49094 /* cut away quotes by replacing them with 0 */
49095 if ((c == '\'') || (c == '"'))
49096 {
49097 q = c;
49098 usetat(argv_buf+pos, 0, 0);
49099 pos += ucwidth(0);
49100 c = ugetc(argv_buf+pos);
49101 }
49102 else
49103 {
49104 q = 0;
49105 }
49106
49107 /* search for the end of the word */
49108 while ((c) && ((q) ? (c != q) : (!uisspace(c))))
49109 {
49110 pos += ucwidth(c);
49111 c = ugetc(argv_buf+pos);
49112 }
49113 }
49114 }
49115
49116 /* now that we know how many words there are in the buffer, allocate enough
49117 * space for a list of pointers to them, or return 0 if there are no words
49118 */
49119 if (ac > 0)
49120 {
49121 config_argv = (char**)_AL_MALLOC(ac*sizeof *config_argv);
49122 }
49123 else
49124 {
49125 *argc = 0;
49126 return NULL;
49127 }
49128
49129 /* go through the tokenized buffer and assign pointers in argv to point to
49130 * the beginning of each individual word
49131 */
49132 for (i=0,pos=0,c=ugetc(argv_buf); i<ac; i++)
49133 {
49134 /* find next word */
49135 while (!c)
49136 {
49137 pos += ucwidth(c);
49138 c = ugetc(argv_buf+pos);
49139 }
49140
49141 /* assign pointer */
49142 config_argv[i] = argv_buf+pos;
49143
49144 /* find end of the word */
49145 while (c)
49146 {
49147 pos += ucwidth(c);
49148 c = ugetc(argv_buf+pos);
49149 }
49150 }
49151
49152 *argc = ac;
49153 return config_argv;
49154 }
49155
49156
49157
49158 /* zscript_insert_config_variable:
49159 * Helper for inserting a new variable into a configuration file.
49160 */
49161 ZSCRIPT_CONFIG_ENTRY *zscript_insert_config_variable(ZSCRIPT_CONFIG *the_config, ZSCRIPT_CONFIG_ENTRY *p, const char *name, const char *data)
49162 {
49163 ZSCRIPT_CONFIG_ENTRY *n = (struct ZSCRIPT_CONFIG_ENTRY*)_AL_MALLOC(sizeof(ZSCRIPT_CONFIG_ENTRY));
49164
49165 if (!n)
49166 return NULL;
49167
49168 if (name)
49169 n->name = _al_ustrdup(name);
49170 else
49171 n->name = NULL;
49172
49173 if (data)
49174 n->data = _al_ustrdup(data);
49175 else
49176 n->data = NULL;
49177
49178 if (p)
49179 {
49180 n->next = p->next;
49181 p->next = n;
49182 }
49183 else
49184 {
49185 n->next = NULL;
49186 the_config->head = n;
49187 }
49188
49189 return n;
49190 }
49191
49192
49193
49194 /* zscript_set_config_string:
49195 * Writes a string to the configuration file.
49196 */
49197 void zscript_set_config_string(const char *section, const char *name, const char *val)
49198 {
49199 ZSCRIPT_CONFIG *the_config;
49200 ZSCRIPT_CONFIG_HOOK *hook;
49201 ZSCRIPT_CONFIG_ENTRY *p, *prev;
49202 char section_name[256];
49203
49204 zscript_init_config(TRUE);
49205
49206 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
49207
49208 /* check for hooked sections */
49209 hook = config_hook;
49210
49211 while (hook)
49212 {
49213 if (ustricmp(section_name, hook->section) == 0)
49214 {
49215 if (hook->stringsetter)
49216 hook->stringsetter(name, val);
49217 return;
49218 }
49219 hook = hook->next;
49220 }
49221
49222 /* decide which config file to use */
49223 if ((ugetc(name) == '#') || ((ugetc(section_name) == '[') && (ugetat(section_name, 1) == '#')))
49224 the_config = system_config;
49225 else if (config_override)
49226 the_config = config_override;
49227 else
49228 the_config = config[0];
49229
49230 if (the_config)
49231 {
49232 p = zscript_find_config_string(the_config, section_name, name, &prev);
49233
49234 if (p)
49235 {
49236 if ((val) && (ugetc(val)))
49237 {
49238 /* modify existing variable */
49239 if (p->data)
49240 _AL_FREE(p->data);
49241
49242 p->data = _al_ustrdup(val);
49243 }
49244 else
49245 {
49246 /* delete variable */
49247 if (p->name)
49248 _AL_FREE(p->name);
49249
49250 if (p->data)
49251 _AL_FREE(p->data);
49252
49253 if (prev)
49254 prev->next = p->next;
49255 else
49256 the_config->head = p->next;
49257
49258 _AL_FREE(p);
49259 }
49260 }
49261 else
49262 {
49263 if ((val) && (ugetc(val)))
49264 {
49265 /* add a new variable */
49266 if (ugetc(section_name))
49267 {
49268 p = zscript_find_config_string(the_config, NULL, section_name, &prev);
49269
49270 if (!p)
49271 {
49272 /* create a new section */
49273 p = the_config->head;
49274 while ((p) && (p->next))
49275 p = p->next;
49276
49277 if ((p) && (p->data) && (ugetc(p->data)))
49278 p = zscript_insert_config_variable(the_config, p, NULL, NULL);
49279
49280 p = zscript_insert_config_variable(the_config, p, section_name, NULL);
49281 }
49282
49283 /* append to the end of the section */
49284 while ((p) && (p->next) &&
49285 (((p->next->name) && (ugetc(p->next->name))) ||
49286 ((p->next->data) && (ugetc(p->next->data)))))
49287 {
49288 p = p->next;
49289 }
49290
49291 p = zscript_insert_config_variable(the_config, p, name, val);
49292 }
49293 else
49294 {
49295 /* global variable */
49296 p = the_config->head;
49297 zscript_insert_config_variable(the_config, NULL, name, val);
49298 the_config->head->next = p;
49299 }
49300 }
49301 }
49302
49303 the_config->dirty = TRUE;
49304 }
49305 }
49306
49307
49308
49309 /* zscript_set_config_int:
49310 * Writes an integer to the configuration file.
49311 */
49312 void zscript_set_config_int(const char *section, const char *name, int32_t val)
49313 {
49314 char buf[32], tmp[32];
49315 uszprintf(buf, sizeof(buf), uconvert_ascii("%d", tmp), val);
49316 zscript_set_config_string(section, name, buf);
49317 }
49318
49319
49320
49321 /* zscript_set_config_hex:
49322 * Writes a hexadecimal integer to the configuration file.
49323 */
49324 void zscript_set_config_hex(const char *section, const char *name, int32_t val)
49325 {
49326 char buf[32], tmp[32];
49327
49328 if (val >= 0)
49329 {
49330 uszprintf(buf, sizeof(buf), uconvert_ascii("%X", tmp), val);
49331 zscript_set_config_string(section, name, buf);
49332 }
49333 else
49334 zscript_set_config_string(section, name, uconvert_ascii("-1", buf));
49335 }
49336
49337
49338
49339 /* zscript_set_config_float:
49340 * Writes a float to the configuration file.
49341 */
49342 void zscript_set_config_float(const char *section, const char *name, float val)
49343 {
49344 char buf[32], tmp[32];
49345 uszprintf(buf, sizeof(buf), uconvert_ascii("%f", tmp), val);
49346 zscript_set_config_string(section, name, buf);
49347 }
49348
49349
49350
49351 /* zscript_set_config_id:
49352 * Writes a driver ID to the configuration file.
49353 */
49354 void zscript_set_config_id(const char *section, const char *name, int32_t val)
49355 {
49356 char buf[32], tmp[32];
49357 int32_t v[4];
49358 int32_t pos = 0;
49359 int32_t i;
49360
49361 if (val < 256)
49362 {
49363 uszprintf(buf, sizeof(buf), uconvert_ascii("%d", tmp), val);
49364 }
49365 else
49366 {
49367 v[0] = (val>>24)&0xFF;
49368 v[1] = (val>>16)&0xFF;
49369 v[2] = (val>>8)&0xFF;
49370 v[3] = val&0xFF;
49371
49372 for (i=0; (i<4) && (v[i]) && (v[i] != ' '); i++)
49373 pos += usetc(buf+pos, v[i]);
49374
49375 usetc(buf+pos, 0);
49376 }
49377
49378 zscript_set_config_string(section, name, buf);
49379 }
49380
49381
49382
49383 /* _zscript_reload_config:
49384 * Internal helper to reload the configuration from allegro_init, in case
49385 * zscript_set_config_file was called before allegro_init.
49386 */
49387 void _zscript_reload_config(void)
49388 {
49389 if (config[0])
49390 {
49391 char *name = _al_ustrdup(config[0]->filename);
49392 zscript_set_config_file(name);
49393 _AL_FREE(name);
49394 }
49395 }
49396
49397
49398
49399 /* zscript_reload_config_texts:
49400 * Reads in a block of translated system text, looking for either a
49401 * user-specified file, a ??text.cfg file, or a language.dat#??TEXT_CFG
49402 * datafile object. If new_language is not NULL, the language config
49403 * variable will be set to new_language before reloading the
49404 * configuration files.
49405 */
49406 void zscript_reload_config_texts(const char *new_language)
49407 {
49408 char filename[1024], tmp1[128], tmp2[128];
49409 const char *name, *ext, *datafile;
49410 char *namecpy;
49411
49412 if (config_language)
49413 {
49414 zscript_destroy_config(config_language);
49415 config_language = NULL;
49416 }
49417
49418 if (new_language)
49419 zscript_set_config_string("system", "language", new_language);
49420
49421 name = zscript_get_config_string(uconvert_ascii("system", tmp1), uconvert_ascii("language", tmp2), NULL);
49422
49423 if ((name) && (ugetc(name)))
49424 {
49425 namecpy = _al_ustrdup(name);
49426 ustrlwr (namecpy);
49427 if ((ustrlen(namecpy)<4) || (ustricmp(namecpy+uoffset(namecpy, -4), uconvert_ascii("text", tmp1)) != 0))
49428 ext = uconvert_ascii("text.cfg", tmp1);
49429 else
49430 ext = uconvert_ascii(".cfg", tmp1);
49431
49432 datafile = uconvert_ascii("language.dat", tmp2);
49433
49434 if (find_allegro_resource(filename, namecpy, ext, datafile, NULL, NULL, NULL, sizeof(filename)) == 0)
49435 {
49436 _AL_FREE(namecpy);
49437 zscript_load_config_file(&config_language, filename, NULL);
49438 return;
49439 }
49440
49441 _AL_FREE(namecpy);
49442 }
49443
49444 config_language = (struct ZSCRIPT_CONFIG*)_AL_MALLOC(sizeof(ZSCRIPT_CONFIG));
49445 if (config_language )
49446 {
49447 config_language ->head = NULL;
49448 config_language ->filename = NULL;
49449 config_language ->dirty = FALSE;
49450 }
49451 }
49452
49453
49454
49455 /* zscript_get_config_text:
49456 * Looks up a translated version of the specified English string,
49457 * returning a suitable message in the current language if one is
49458 * available, or a copy of the parameter if no translation can be found.
49459 */
49460 const char *zscript_get_config_text(const char *msg)
49461 {
49462 char tmp1[256];
49463 const char *section;
49464 const char *umsg;
49465 const char *s;
49466 const char *ret = NULL;
49467 char *name;
49468 ZSCRIPT_CONFIG_HOOK *hook;
49469 ZSCRIPT_CONFIG_ENTRY *p;
49470 int32_t c, pos, size;
49471 ASSERT(msg);
49472
49473 /* Hack: the inline definition of install_allegro() from 4.2.0 calls
49474 * zscript_get_config_text() even before Allegro has been initialised, leading
49475 * to a crash in get_executable_name(). To retain binary compatibility
49476 * we check for this case.
49477 */
49478 if (_allegro_count == 0)
49479 {
49480 return msg;
49481 }
49482
49483 zscript_init_config(TRUE);
49484
49485 section = uconvert_ascii("[language]", tmp1);
49486
49487 /* allocate memory and convert message to current encoding format */
49488 if (need_uconvert(msg, U_ASCII, U_CURRENT))
49489 {
49490 size = uconvert_size(msg, U_ASCII, U_CURRENT);
49491 umsg = (char*)_AL_MALLOC_ATOMIC(size);
49492 if (!umsg)
49493 {
49494 *allegro_errno = ENOMEM;
49495 return empty_string;
49496 }
49497
49498 name = (char*)_AL_MALLOC_ATOMIC(size);
49499 if (!name)
49500 {
49501 _AL_FREE((char *)umsg); /* remove constness */
49502 *allegro_errno = ENOMEM;
49503 return empty_string;
49504 }
49505
49506 do_uconvert(msg, U_ASCII, (char*)umsg, U_CURRENT, size);
49507 }
49508 else
49509 {
49510 umsg = msg;
49511 name = (char*)_AL_MALLOC_ATOMIC(ustrsizez(msg));
49512 if (!name)
49513 {
49514 *allegro_errno = ENOMEM;
49515 return empty_string;
49516 }
49517 }
49518
49519 s = umsg;
49520 pos = 0;
49521
49522 while ((c = ugetxc(&s)) != 0)
49523 {
49524 if ((uisspace(c)) || (c == '=') || (c == '#'))
49525 pos += usetc(name+pos, '_');
49526 else
49527 pos += usetc(name+pos, c);
49528 }
49529
49530 usetc(name+pos, 0);
49531
49532 /* check for hooked sections */
49533 hook = config_hook;
49534
49535 while (hook)
49536 {
49537 if (ustricmp(section, hook->section) == 0)
49538 {
49539 if (hook->stringgetter)
49540 {
49541 ret = hook->stringgetter(name, umsg);
49542 break;
49543 }
49544 }
49545
49546 hook = hook->next;
49547 }
49548
49549 if (!ret)
49550 {
49551 /* find the string */
49552 p = zscript_find_config_string(config_override, section, name, NULL);
49553
49554 if (!p)
49555 {
49556 p = zscript_find_config_string(config[0], section, name, NULL);
49557
49558 if (!p)
49559 p = zscript_find_config_string(config_language, section, name, NULL);
49560 }
49561
49562 if (p)
49563 {
49564 ret = (p->data ? p->data : empty_string);
49565 }
49566 else
49567 {
49568 /* no translation, so store off this value in the file */
49569 p = config_language->head;
49570 zscript_insert_config_variable(config_language, NULL, name, umsg);
49571 config_language->head->next = p;
49572 ret = config_language->head->data;
49573 }
49574 }
49575
49576 /* free memory */
49577 if (umsg!=msg)
49578 _AL_FREE((char*) umsg); /* remove constness */
49579
49580 _AL_FREE(name);
49581
49582 return ret;
49583 }
49584
49585
49586
49587 /* zscript_add_unique_config_name
49588 * Helper to add a name to a list of names.
49589 */
49590 int32_t zscript_add_unique_config_name(const char ***names, int32_t n, char const *name)
49591 {
49592 int32_t i;
49593 /* FIXME: use better search algorithm */
49594 for (i = 0; i < n; i++)
49595 if (!ustrcmp((*names)[i], name))
49596 return n;
49597
49598 *names = (const char**)_al_sane_realloc((void *)*names, (n + 1) * sizeof **names);
49599 (*names)[n] = name;
49600 return n + 1;
49601 }
49602
49603
49604
49605 /* zscript_attach_config_entries
49606 * Helper function to attach key or section names to a list of strings.
49607 */
49608 int32_t zscript_attach_config_entries(ZSCRIPT_CONFIG *conf, const char *section, int32_t n, const char ***names, int32_t list_sections)
49609 {
49610 ZSCRIPT_CONFIG_ENTRY *p;
49611 char section_name[256];
49612 int32_t in_section;
49613
49614 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
49615
49616 if (conf)
49617 {
49618 p = conf->head;
49619
49620 /* If section is NULL, only initial, section-less entries are used. */
49621 if (ugetc(section_name))
49622 in_section = FALSE;
49623 else
49624 in_section = TRUE;
49625
49626 while (p)
49627 {
49628 if (p->name)
49629 {
49630 /* a section start is just a list entry enclosed in [] */
49631 if (ugetc(p->name) == '[' && ugetat(p->name, -1) == ']')
49632 {
49633 if (list_sections)
49634 {
49635 n = zscript_add_unique_config_name(names, n, p->name);
49636 }
49637 in_section = (ustricmp(section_name, p->name) == 0);
49638 }
49639 else if (in_section && !list_sections)
49640 {
49641 n = zscript_add_unique_config_name(names, n, p->name);
49642 }
49643 }
49644 p = p->next;
49645 }
49646 }
49647 return n;
49648 }
49649
49650
49651
49652 /* list_config_entires:
49653 * Returns the names of all config entries in a section. The names parameter is
49654 * a pointer to a strings array that will contain the config keys. If it points to
49655 * a NULL pointer, it will be allocated, or else re-allocated accordingly. The
49656 * return value tells how many valid string pointers it contains after the
49657 * function returns.
49658 */
49659 int32_t zscript_list_config_entries(const char *section, const char ***names)
49660 {
49661 int32_t n = 0;
49662 n = zscript_attach_config_entries(config_override, section, n, names, 0);
49663 n = zscript_attach_config_entries(config[0], section, n, names, 0);
49664 return n;
49665 }
49666
49667
49668
49669 /* zscript_list_config_sections:
49670 * Returns the names of all current config sections, enclodes in []. The names
49671 * parameter and return value is like in list_config_entires above.
49672 */
49673 int32_t zscript_list_config_sections(const char ***names)
49674 {
49675 int32_t n = 0;
49676 n = zscript_attach_config_entries(config_override, NULL, n, names, 1);
49677 n = zscript_attach_config_entries(config[0], NULL, n, names, 1);
49678 return n;
49679 }
49680
49681
49682
49683 /* zscript_free_config_entries:
49684 * Frees the entries list returned by list_config_entires or
49685 * zscript_list_config_sections again.
49686 */
49687 void zscript_free_config_entries(const char ***names)
49688 {
49689 _AL_FREE(*names);
49690 *names = NULL;
49691 }
49692
49693 225833 int32_t FFScript::Distance(double x1, double y1, double x2, double y2)
49694 {
49695 225833 double x = (x1-x2);
49696 225833 double y = (y1-y2);
49697 225833 double sum = (x*x)+(y*y);
49698 //if(((int32_t)sum) < 0)
49699 //{
49700 // Z_scripterrlog("Distance() attempted to calculate square root of %ld!\n", ((int32_t)sum));
49701 // return -10000;;
49702 //}
49703 225833 sum *= 1000000.0;
49704 225833 double total = sqrt(sum)*10;
49705 225833 return int32_t(total);
49706 }
49707
49708 int32_t FFScript::Distance(double x1, double y1, double x2, double y2, int32_t scale)
49709 {
49710 double x3 = x1+(x2-x1)/scale;
49711 double y3 = y1+(y2-y1)/scale;
49712 //double sum = (x*x)+(y*y);
49713 //if(((int32_t)sum) < 0)
49714 //{
49715 // Z_scripterrlog("Distance() attempted to calculate square root of %ld!\n", ((int32_t)sum));
49716 // return -10000;
49717 //}
49718 //sum *= 1000000.0;
49719 //double total = sqrt(sum)*10;
49720 //return int32_t(total*scale);
49721 return (FFCore.Distance(x1, y1, x3, y3)*scale);
49722 }
49723
49724 int32_t FFScript::LongDistance(double x1, double y1, double x2, double y2)
49725 {
49726 double x = (x1-x2);
49727 double y = (y1-y2);
49728 double sum = (x*x)+(y*y);
49729 //if(((int32_t)sum) < 0)
49730 //{
49731 // Z_scripterrlog("Distance() attempted to calculate square root of %ld!\n", ((int32_t)sum));
49732 // return -10000;;
49733 //}
49734 double total = sqrt(sum);
49735 return int32_t(total);
49736 }
49737
49738 int32_t FFScript::LongDistance(double x1, double y1, double x2, double y2, int32_t scale)
49739 {
49740 double x3 = x1+(x2-x1)/scale;
49741 double y3 = y1+(y2-y1)/scale;
49742 //double sum = (x*x)+(y*y);
49743 //if(((int32_t)sum) < 0)
49744 //{
49745 // Z_scripterrlog("Distance() attempted to calculate square root of %ld!\n", ((int32_t)sum));
49746 // return -10000;
49747 //}
49748 //sum *= 1000000.0;
49749 //double total = sqrt(sum)*10;
49750 //return int32_t(total*scale);
49751 return (FFCore.LongDistance(x1, y1, x3, y3)*scale);
49752 }
49753
49754 void FFScript::do_distance()
49755 {
49756 double x1 = double(ri->d[rSFTEMP] / 10000.0);
49757 double x2 = double(ri->d[rINDEX] / 10000.0);
49758 double y1 = double(ri->d[rINDEX2] / 10000.0);
49759 double y2 = double(ri->d[rEXP1] / 10000.0);
49760
49761 int32_t result = FFCore.Distance(x1, x2, y1, y2);
49762 //ret = result*10000;
49763
49764 }
49765
49766 41290941 bool command_is_wait(int command)
49767 {
49768
2/2
✓ Branch 0 taken 41286000 times.
✓ Branch 1 taken 4941 times.
41290941 switch (command)
49769 {
49770 case WAITFRAME:
49771 case WAITDRAW:
49772 case WAITTO:
49773 case WAITEVENT:
49774 case WAITFRAMESR:
49775 4941 return true;
49776 }
49777 41286000 return false;
49778 41290941 }
49779
49780 41289657 bool command_uses_comparison_result(int command)
49781 {
49782
2/2
✓ Branch 0 taken 1143318 times.
✓ Branch 1 taken 40146339 times.
41289657 switch (command)
49783 {
49784 case GOTOTRUE:
49785 case GOTOFALSE:
49786 case GOTOMORE:
49787 case GOTOLESS:
49788 case SETTRUE:
49789 case SETTRUEI:
49790 case SETFALSE:
49791 case SETFALSEI:
49792 case SETMOREI:
49793 case SETLESSI:
49794 case SETMORE:
49795 case SETLESS:
49796 1143318 return true;
49797 }
49798 40146339 return false;
49799 41289657 }
49800
49801 489801 bool command_could_return_not_ok(int command)
49802 {
49803
2/2
✓ Branch 0 taken 1525 times.
✓ Branch 1 taken 488276 times.
489801 switch (command)
49804 {
49805 case 0xFFFF:
49806 case EWPNDEL:
49807 case GAMECONTINUE:
49808 case GAMEEND:
49809 case GAMERELOAD:
49810 case GAMESAVECONTINUE:
49811 case GAMESAVEQUIT:
49812 case ITEMDEL:
49813 case LWPNDEL:
49814 case NPCKICKBUCKET:
49815 case SETSCREENDOOR:
49816 case SETSCREENENEMY:
49817 1525 return true;
49818 }
49819 488276 return false;
49820 489801 }
49821
49822 const script_command& get_script_command(int command)
49823 {
49824 return ZASMcommands[command];
49825 }
49826
49827 98563972 int32_t get_combopos_ref(int32_t pos, int32_t layer)
49828 {
49829 98563972 return layer * 176 + pos;
49830 }
49831
49832 94370 int32_t combopos_ref_to_pos(int32_t combopos_ref)
49833 {
49834 94370 return combopos_ref % 176;
49835 }
49836
49837 38089 int32_t combopos_ref_to_layer(int32_t combopos_ref)
49838 {
49839 38089 return combopos_ref / 176;
49840 }
49841